1
0
Fork 0
mirror of https://github.com/lightning/bolts.git synced 2025-03-13 11:35:41 +01:00

Set output amount to 0 when using OP_RETURN

Bitcoin Core version 25+ will not broadcast transactions containing
`OP_RETURN` outputs if their amount is greater than 0, because this
amount would then be unspendable. We thus require that the output
amount is set to 0 when using `OP_RETURN`.
This commit is contained in:
t-bast 2024-10-11 09:37:46 +02:00
parent 4c97b738a0
commit 8f4e2bdc7c
No known key found for this signature in database
GPG key ID: 34F377B0100ED6BB
2 changed files with 11 additions and 5 deletions

View file

@ -1731,7 +1731,10 @@ satoshis, which is possible if `dust_limit_satoshis` is below 546 satoshis).
No funds are at risk when that happens, but the channel must be force-closed as No funds are at risk when that happens, but the channel must be force-closed as
the closing transaction will likely never reach miners. the closing transaction will likely never reach miners.
`OP_RETURN` is only standard if followed by PUSH opcodes, and the total script is 83 bytes or less. We are slightly stricter, to only allow a single PUSH, but there are two forms in script: one which pushes up to 75 bytes, and a longer one (OP_PUSHDATA1) which is needed for 76-80 bytes. `OP_RETURN` is only standard if followed by PUSH opcodes, and the total script
is 83 bytes or less. We are slightly stricter, to only allow a single PUSH, but
there are two forms in script: one which pushes up to 75 bytes, and a longer
one (OP_PUSHDATA1) which is needed for 76-80 bytes.
### Closing Negotiation: `closing_complete` and `closing_sig` ### Closing Negotiation: `closing_complete` and `closing_sig`

View file

@ -407,13 +407,16 @@ The side with lesser funds can opt to omit their own output.
* `txin[0]` sequence: `sequence` from `closing_complete` message * `txin[0]` sequence: `sequence` from `closing_complete` message
* `txin[0]` script bytes: 0 * `txin[0]` script bytes: 0
* `txin[0]` witness: `0 <signature_for_pubkey1> <signature_for_pubkey2>` * `txin[0]` witness: `0 <signature_for_pubkey1> <signature_for_pubkey2>`
* txout count: 1 or 2 * txout count: 1 or 2
* The closer output: * The closer output:
* `txout` amount: the final balance for the closer, minus `closing_complete` `fee_satoshis`, rounded down to whole satoshis. * `txout` amount:
* 0 if the `scriptpubkey` starts with `OP_RETURN`
* otherwise the final balance for the closer, minus `closing_complete.fee_satoshis`, rounded down to whole satoshis
* `txout` script: as specified in that closer's `scriptpubkey` in its `shutdown` message * `txout` script: as specified in that closer's `scriptpubkey` in its `shutdown` message
* The closee output: * The closee output:
* `txout` amount: the final balance for the closee, rounded down to whole satoshis. * `txout` amount:
* 0 if the `scriptpubkey` starts with `OP_RETURN`
* otherwise the final balance for the closee, rounded down to whole satoshis
* `txout` script: as specified in that closee's `scriptpubkey` in its `shutdown` message * `txout` script: as specified in that closee's `scriptpubkey` in its `shutdown` message
### Requirements ### Requirements
@ -421,7 +424,7 @@ The side with lesser funds can opt to omit their own output.
Each node offering a signature: Each node offering a signature:
- MUST round each output down to whole satoshis. - MUST round each output down to whole satoshis.
- MUST subtract the fee given by `fee_satoshis` from the closer output. - MUST subtract the fee given by `fee_satoshis` from the closer output.
- MUST set the output amount to 0 if the `scriptpubkey` is `OP_RETURN`.
## Fees ## Fees