Add note to RFC005 highlighting the little-endian encoding of refund_timestamp#100
Conversation
| |20 | ||
| |=== | ||
|
|
||
| CAUTION: The `refund_timestamp` is of length 4 which means we https://github.com/bitcoin/bitcoin/blob/29082e8f40c360847882553ad1b3900e5e402688/src/script/script.h#L229-L246[have to use] the `OP_PUSHDATA4` op code to keep the script minimal. Data pushed using either `OP_PUSHDATA2` or `OP_PUSHDATA4` MUST be encoded in https://en.bitcoin.it/wiki/Script#Constants[*little-endian*]. Hence, you MUST convert `refund_timestamp` to *little-endian* before constructing the HTLC from its parameters. |
There was a problem hiding this comment.
The link you posted states: When used as numbers, byte vectors are interpreted as little-endian, so I tried to find why pub-keys are not little-endian but couldn't find a reason. Just this: Public keys (in scripts) are given as 04 <x> <y> where x and y are 32 byte big-endian integers representing the coordinates of a point on the curve or in compressed form given as <sign> <x> where <sign> is 0x02 if y is even and 0x03 if y is odd.
which did not really help at all :S
https://en.bitcoin.it/wiki/Protocol_documentation#Signatures
There was a problem hiding this comment.
I assumed that the OP codes just know how to interpret that data.
D4nte
left a comment
There was a problem hiding this comment.
I am confused, sometimes you use link: and sometimes not. What is the difference?
All good otherwise.
| link:./RFC-003-SWAP-Basic.md[RFC003] requires ledgers have an *identity* type specified to negotiate a SWAP. | ||
|
|
||
| The Identity to be used on Bitcoin is the 20-byte *pubkeyhash* which is the result of applying SHA-256 and then RIPEMD-160 to a user's compressed SECP256k1 public key. | ||
| The compressed public key is used because it needs to be compatible with segwit transactions (see https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#Restrictions_on_public_key_type)[BIP143]). |
There was a problem hiding this comment.
| The compressed public key is used because it needs to be compatible with segwit transactions (see https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#Restrictions_on_public_key_type)[BIP143]). | |
| The compressed public key is used because it needs to be compatible with segwit transactions (see link:https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#Restrictions_on_public_key_type)[BIP143]). |
| ``` | ||
|
|
||
| As required by link:./RFC-003-SWAP-Basic.md[RFC003], this HTLC uses absolute time locks to check whether `refund_timestamp` has been reached. | ||
| Specifically, `OP_CHECKLOCKTIMEVERIFY` (see https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki)[BIP65]) is used to compare the time in the block's header to the `refund_timestamp` in the contract. |
There was a problem hiding this comment.
| Specifically, `OP_CHECKLOCKTIMEVERIFY` (see https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki)[BIP65]) is used to compare the time in the block's header to the `refund_timestamp` in the contract. | |
| Specifically, `OP_CHECKLOCKTIMEVERIFY` (see link:https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki)[BIP65]) is used to compare the time in the block's header to the `refund_timestamp` in the contract. |
| As required by link:./RFC-003-SWAP-Basic.md[RFC003], this HTLC uses absolute time locks to check whether `refund_timestamp` has been reached. | ||
| Specifically, `OP_CHECKLOCKTIMEVERIFY` (see https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki)[BIP65]) is used to compare the time in the block's header to the `refund_timestamp` in the contract. | ||
|
|
||
| Implementations MUST consider an `refund_timestamp` value below `500000000` for a Bitcoin HTLC to be invalid due to the https://en.bitcoin.it/wiki/Protocol_documentation#tx[`lock_time`] transaction field interpreting values below `500000000` as block heights. |
There was a problem hiding this comment.
| Implementations MUST consider an `refund_timestamp` value below `500000000` for a Bitcoin HTLC to be invalid due to the https://en.bitcoin.it/wiki/Protocol_documentation#tx[`lock_time`] transaction field interpreting values below `500000000` as block heights. | |
| Implementations MUST consider an `refund_timestamp` value below `500000000` for a Bitcoin HTLC to be invalid due to the link:https://en.bitcoin.it/wiki/Protocol_documentation#tx[`lock_time`] transaction field interpreting values below `500000000` as block heights. |
https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#links |
The PR first converts the RFC to AsciiDoc and then uses admonitions to add the note.
Unfortunately, the conversion is too much for GitHub's git settings to detect that is actually the same file.
You can go check it locally using
git diff master -M1which lowers the similarity setting to 10%.Fixes #93.