<p>You cannot broadcast an incomplete transaction and have another user modify it later, because an incomplete transaction is not valid and invalid transactions do not propagate on the network.</p>
<p>You could share an incomplete transaction out-of-band, e.g. on a message board, via a <a href="https://bitcoinops.org/en/topics/psbt/" rel="nofollow noreferrer">Partially signed Bitcoin transaction (PSBT)</a> <em>iff</em> the inputs and outputs of the transaction creator are sufficient to enforce their expected outcome by using a <code>SIGHASH_SINGLE | SIGHASH_ANYONECANPAY</code> construction. The second participant would then be able to fill in the remaining inputs and outputs to achieve their intended outcome in addition.</p>
<p>However, if you want two participants to both have input on one output script, your protocol will require at least one round trip, as the original transaction creator cannot sign off on an incomplete output script, and therefore either the second participant would have the ability to unilaterally determine that output or the transaction would have to go back to the creator after the second participant adds their modification.</p>
<p>I must admit that I don’t fully understand what you are trying to achieve, and therefore may be missing a workaround or trick, but the above should cover the general situation. Your problem reminds me of how inscription market places use PSBTs to offer NFTs for sale, and if you are not familiar, it might be interesting to study that approach.</p>
<p>If you generally want to better understand how HTLCs work, you may want to take a look at Elle Mouton’s excellent <a href="https://ellemouton.com/posts/htlc-deep-dive/" rel="nofollow noreferrer">HTLC Deep Dive</a>, her other blog posts may also be interesting in the context of your line of inquiry.</p>

CC BY-SA 4.0
2024-06-26T13:35:13.143Z
2024-06-28T14:48:27.530Z
2024-06-28T14:48:27.530Z
Murch
<p>I'm currently working on implementing a modified version of Hash Time Locked Contracts (HTLC) in Bitcoin and would greatly appreciate any guidance or best practices from the community.</p>
<h3>Objective: I aim to modify the standard HTLC to simplify the creation process. In my modified HTLC:</h3>
<ol>
<li>The creator of the HTLC does not need to specify a hash lock initially.</li>
<li>The creator specifies a party (which can be nullable) who will later add the hash lock to the pre-HTLC.</li>
<li>Only the creator of the pre-HTLC and the specified party can add the hash lock.</li>
</ol>
<h3>Questions:</h3>
<ol>
<li><strong>Feasibility</strong>: Can this modification be implemented within the current Bitcoin scripting capabilities? Are there any inherent limitations I should be aware of?</li>
<li><strong>Security Considerations</strong>: What potential security risks should I consider with this modification? How can I mitigate these risks?</li>
</ol>

CC BY-SA 4.0
2024-06-25T13:40:38.233Z
Am I understanding right that you are trying to create an output which will execute differently based on someone else’s input _after it was created_?
Murch
CC BY-SA 4.0
2024-06-25T13:48:55.650Z
@Murch let me explain more detailed.in simple HTLC when Alice and Bob want to change assets,at first Alice creates HTLC struct and lock funds for Bob with inputs (hashlock,BobAddr,timelock,amount,etc).In modified version I want Alice to create preHTLC struct for Bob with inputs (3rdParty,BobAddr,timelock,amount,etc),after it 3rdParty comes and converts preHTLC creating new struct HTLC with preHTLC data and adds hashlock. Afters this step everything goes as in simple HTLC protocol.
Nerses Asaturyan
CC BY-SA 4.0
2024-06-25T18:54:17.593Z
Are you aware of PSBTs?
Murch
CC BY-SA 4.0
2024-06-26T09:11:02.520Z
unfortunately,no
Nerses Asaturyan
CC BY-SA 4.0
2024-06-26T09:18:34.583Z
I have done some research,but I still cant understand will it match to the described architecture.Particularly that 3rdParty can be nullable,will work PSBT for it.
Nerses Asaturyan
CC BY-SA 4.0
2024-06-26T13:25:36.497Z
You would need a separate way for the participants to agree on the output script, and then could use PSBTs to coordinate transaction assembly and signatures. You cannot broadcast an incomplete transaction and have it modified afterwards, because an incomplete transaction is not valid and invalid transactions do not propagate on the network.
Murch
CC BY-SA 4.0
2024-06-26T13:34:41.370Z
thanks for help
Nerses Asaturyan
<script><bitcoinjs><hash-time-locked-contract><smartcontracts><implementation>
modified Hash Time Locked Contracts
Nerses Asaturyan
# modified Hash Time Locked Contracts

(Asked by: username_0 on 2024-06-25)

I'm currently working on implementing a modified version of Hash Time Locked Contracts (HTLC) in Bitcoin and would greatly appreciate any guidance or best practices from the community.

### Objective: I aim to modify the standard HTLC to simplify the creation process. In my modified HTLC:

1. The creator of the HTLC does not need to specify a hash lock initially.
2. The creator specifies a party (which can be nullable) who will later add the hash lock to the pre-HTLC.
3. Only the creator of the pre-HTLC and the specified party can add the hash lock.

### Questions:

1. **Feasibility**: Can this modification be implemented within the current Bitcoin scripting capabilities? Are there any inherent limitations I should be aware of?
2. **Security Considerations**: What potential security risks should I consider with this modification? How can I mitigate these risks?

**Tags:** script, bitcoinjs, hash-time-locked-contract, smartcontracts, implementation

> **Comments:**
> **username_1**: Am I understanding right that you are trying to create an output which will execute differently based on someone else’s input _after it was created_?  
> **username_0**: @username_1 let me explain more detailed.in simple HTLC when Alice and Bob want to change assets,at first Alice creates HTLC struct and lock funds for Bob with inputs (hashlock,BobAddr,timelock,amount,etc).In modified version I want Alice to create preHTLC struct for Bob with inputs (3rdParty,BobAddr,timelock,amount,etc),after it 3rdParty comes and converts preHTLC creating new struct HTLC with preHTLC data and adds hashlock. Afters this step everything goes as in simple HTLC protocol.  
> **username_1**: Are you aware of PSBTs?  
> **username_0**: unfortunately,no  
> **username_0**: I have done some research,but I still cant understand will it match to the described architecture.Particularly that 3rdParty can be nullable,will work PSBT for it.  
> **username_1**: You would need a separate way for the participants to agree on the output script, and then could use PSBTs to coordinate transaction assembly and signatures. You cannot broadcast an incomplete transaction and have it modified afterwards, because an incomplete transaction is not valid and invalid transactions do not propagate on the network.  
> **username_0**: thanks for help  

---

## 1 answers

### Answer by username_1 on 2024-06-26. Score: 0

You cannot broadcast an incomplete transaction and have another user modify it later, because an incomplete transaction is not valid and invalid transactions do not propagate on the network.

You could share an incomplete transaction out-of-band, e.g. on a message board, via a [Partially signed Bitcoin transaction (PSBT)](https://bitcoinops.org/en/topics/psbt/) *iff* the inputs and outputs of the transaction creator are sufficient to enforce their expected outcome by using a `SIGHASH_SINGLE | SIGHASH_ANYONECANPAY` construction. The second participant would then be able to fill in the remaining inputs and outputs to achieve their intended outcome in addition.

However, if you want two participants to both have input on one output script, your protocol will require at least one round trip, as the original transaction creator cannot sign off on an incomplete output script, and therefore either the second participant would have the ability to unilaterally determine that output or the transaction would have to go back to the creator after the second participant adds their modification.

I must admit that I don’t fully understand what you are trying to achieve, and therefore may be missing a workaround or trick, but the above should cover the general situation. Your problem reminds me of how inscription market places use PSBTs to offer NFTs for sale, and if you are not familiar, it might be interesting to study that approach.

If you generally want to better understand how HTLCs work, you may want to take a look at Elle Mouton’s excellent [HTLC Deep Dive](https://ellemouton.com/posts/htlc-deep-dive/), her other blog posts may also be interesting in the context of your line of inquiry.


---

