diff --git a/02-peer-protocol.md b/02-peer-protocol.md index 38e2b72ac..7bd81682b 100644 --- a/02-peer-protocol.md +++ b/02-peer-protocol.md @@ -199,6 +199,14 @@ This message contains a transaction input. * [`u32`:`prevtx_vout`] * [`u32`:`sequence`] +1. `tlv_stream`: `tx_add_input_tlvs` +2. types: + 1. type: 0 (`prevtxout`) + 2. data: + * [`sha256`:`txid`] + * [`u64`:`amount_satoshis`] + * [`...*byte`:`scriptpubkey`] + #### Requirements The sending node: @@ -206,6 +214,8 @@ The sending node: - MUST use a unique `serial_id` for each input currently added to the transaction - MUST set `sequence` to be less than or equal to 4294967293 (`0xFFFFFFFD`) + - If the input is using segwit version 1 or greater: + - MAY omit `prevtx` and send `prevtxout` instead - MUST NOT re-transmit inputs it has received from the peer - if is the *initiator*: - MUST send even `serial_id`s @@ -216,11 +226,12 @@ The receiving node: - MUST add all received inputs to the transaction - MUST fail the negotiation if: - `sequence` is set to `0xFFFFFFFE` or `0xFFFFFFFF` - - the `prevtx` and `prevtx_vout` are identical to a previously added - (and not removed) input's - - `prevtx` is not a valid transaction + - `prevtx` and `prevtxout` are both missing + - `prevtx` is provided and is not a valid transaction - `prevtx_vout` is greater or equal to the number of outputs on `prevtx` - - the `scriptPubKey` of the `prevtx_vout` output of `prevtx` is not exactly a 1-byte push opcode (for the numeric values `0` to `16`) followed by a data push between 2 and 40 bytes + - the spent outpoint is identical to a previously added (and not removed) input's + - the `scriptpubkey` of the `prevtx_vout` output of `prevtx` is not exactly a 1-byte push opcode (for the numeric values `0` to `16`) followed by a data push between 2 and 40 bytes + - the `scriptpubkey` of `prevtxout` is not exactly a 1-byte push opcode (for the numeric values `1` to `16`) followed by a data push between 2 and 40 bytes - the `serial_id` is already included in the transaction - the `serial_id` has the wrong parity - if has received 4096 `tx_add_input` messages during this negotiation @@ -235,6 +246,9 @@ Inputs in the constructed transaction MUST be sorted by `serial_id`. `prevtx` is the serialized transaction that contains the output this input spends. Used to verify that the input is non-malleable. +When using segwit version 1 or higher, we only need to provide the +`prevtxout` instead: this is particularly useful when the previous +transaction is too large to be included in a lightning message. `prevtx_vout` is the index of the output being spent.