Are you trying to have a presigned transaction where the outputs are unknown. Then you can add outputs afterwards without having to sign again?
Exactly ... only that I wanted to specify a condition in the first transaction (let's call it "transaction A") to avoid that someone simply changed the outputs, as you wrote.
I see maybe I am formulating my goal a bit complicated, so I try to write it in "Alice & Bob" manner. The goal is an "universal gift card without centralized management":
- Alice owns 1 Bitcoin.
- Alice wants to go shopping. However, she doesn't want to take her private key with her on a device (or paper) because if it's stolen she loses the whole BTC. But she wants to be able to spend up to 1 BTC, so creating a wallet with a smaller balance is not an option. So she wants to create "coupons" to be spent in the shop(s).
- Additionally, she wants to re-use these "coupons", if she spends money in several shops. This is why she doesn't want to specify the input to be spent in the coupon.
- Bob is the shop owner where she ends buying, but Alice doesn't know in advance where she will buy something (so she cannot simply pre-sign transactions to his address, that would be regular "Bitcoin gift cards" like we already know).
The original idea is almost the same one @Coding Enthusiast described: Alice creates a transaction with a special output (transaction A) which authorizes anyone fulfilling a certain condition (knowing a secret) to spend the 1 BTC. This transaction is broadcasted and confirmed before she begins shopping. When she pays Bob, she shares the secret with him, and Bob is thus authorized to spend a part of the transaction (transaction B).
Now Bob in theory could spend the whole Bitcoin once he knows the secret. That's why my idea was that Alice, instead of providing him an "arbitrary" secret, could specify an slightly different condition:
1) She creates a list of values of the BTC she may want to spend (e.g. 0.1, 0.2, 0.3 ... BTC), and signs each item of the list without specifying the output, with the rest returning to her change address. Each of these items would be, essentially, a "signed transaction without specified input and with incomplete output". She prints them on paper.
2) In transaction A, she specifies that only the value that is signed with her private key can be spent by the shop owner. (This is what may not be possible with current opcodes, if I understand both your posts correctly).
Bob then broadcast transaction B to his own address, providing both Alice's "pre-signed incomplete transaction" as secret, and spending Alice's special output of Transaction A.
However this setup would be equally unsafe than the one with the simple secret, because when Bob shares Alice's pre-signed "incomplete transaction" , then anyone listening to the Bitcoin network could try to double-spend that transaction with another output.
Maybe, however, there is a way for Alice to provide an additional condition: In the pre-signed transaction she handles to Bob, a hash of an additional secret could be specified which must be known by Bob to spend the output of transaction B in a new transaction (transaction C). In this case, if someone double-spends the output of transaction A, (creating transaction B* to his own address), he won't be able to spend the output of transaction B*.
I hope my goal is clearer now ...
Furthermore, you cannot use opcodes to restrict the recipients because opcodes cannot inspect other inputs and outputs of the transaction they are in.
OK, sounds logical. However, I think in my setup the output of transaction A checks only transaction B and Alice's public key (to know that's she who is signing the "incomplete transaction"), and transaction B the output of transaction C, or not?