1
0
mirror of https://github.com/lightning/bolts.git synced 2024-11-19 10:00:04 +01:00
Commit Graph

71 Commits

Author SHA1 Message Date
Rusty Russell
4dc97605cc BOLT 3: define closing transaction.
The only surprise here (maybe?) is that we use the commitment number encoding.
I think that makes sense, but it was unspecified before.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-08 10:05:18 +09:30
Rusty Russell
95e7196560 BOLT 3: fix references to RIPEMD160(revocationkey)
They should be HASH160, aka RIPEMD160(SHA256()).

Closes: #179
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-23 17:56:53 +02:00
Olaoluwa Osuntokun
61b5b3f7b4 BOLT 3: clarify description of revocation key derivation (#170)
This commit attempts to clarify some ambiguity in the way the
revocation key derivation was formerly described. Rather than framing
the description in terms of local vs remote nodes, we instead frame the
description around the _process_ of creating a new commitment
transaction for a remote node,

[ minor typos and remove weird part-sentence -- RR ]
2017-05-20 09:50:51 +09:30
Rusty Russell
f0da3978e9 Underscores for all terms, not just fields.
Plus a few more missing ones, and some consistency fixes in names
as pointed out by Roasbeed and Fabrice.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-15 12:54:53 -07:00
Rusty Russell
5f06896403 BOLT 3: instead of ripemd-of-X, use RIPEMD160(X).
This is more specific and clearer.

Reported-by: Olaoluwa Osuntokun <laolu32@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-15 12:54:53 -07:00
Rusty Russell
63edd2e869 BOLT 3: use correct field name for HTLC timeout value.
It's called cltv_expiry in BOLT 2's update_add_htlc.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-15 12:54:53 -07:00
Rusty Russell
407b9927bf BOLT 3: Replace many hyphens with underscores in descriptions.
Not sure how I missed these:
1. funding-pubkey -> funding_pubkey
2. to-self-delay -> to_self_delay
3. per-commitment-point -> per_commitment_point
4. per-commitment-secret -> per_commitment_secret
5. revocation-basepoint -> revocation_basepoint
6. delayed-payment-basepoint -> delayed_payment_basepoint
7. payment-basepoint -> payment_basepoint

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-15 12:54:53 -07:00
Rusty Russell
c0fa965036 BOLT 3: Add URL for BIP69.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-11 11:20:36 +09:30
Rusty Russell
8c0e55ac37 BOLT 4: underscores and backticks everywhere.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-11 11:20:36 +09:30
Rusty Russell
925b39a619 BOLT 3: typo fixes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-03 13:08:07 +09:30
Rusty Russell
5ed243de2d BOLT 3: fix labels on test vectors.
As per ElementsProject/lightning#134 Fabrice points out that to calculate
our own commitment tx, we use the *other* side's revocation basepoint:

	The revocationkey is a blinded key: the remote node provides the base,
	and the local node provides the blinding factor which it later
	reveals

Thus, we fix the test vectors by renaming "local_revocation_basepoint"
to "remote_revocation_basepoint", which is what we should be using.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-24 12:24:24 +10:30
Rusty Russell
e6aa70ebc0 BOLT 3: update test vectors for new scripts and weight calculation.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-08 05:50:44 +10:30
Rusty Russell
aeb6e45d7e BOLT 3: fix internal remote_secret_key documentation.
We didn't update it for 394da29189
"BOLT 3: fix test vector derivation."

This doesn't actually change any results, just fixes an intermediate
calculation.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-08 05:50:44 +10:30
Rusty Russell
7c59d6990b BOLT 3: update numbers in example calculation.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-08 05:50:44 +10:30
Rusty Russell
392008a7d3 BOLT 3,5: update weight calculations for revocation key hash in script.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-08 05:50:44 +10:30
Rusty Russell
a597738b94 BOLT 3: Use revocation key hash rather than revocation key in scripts.
This means more bytes if we need to create a penalty tx, but less for
normal operation:

Witness script for offered htlcs: 139 bytes -> 133 bytes.
Witness script for accepted htlcs: 156 bytes -> 139 bytes.

It's also a little simpler; it's just an OP_IF around the old scripts
to test for the revocation key being the top arg.

Suggested-by: Joseph Poon <joseph@lightning.network>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-08 05:50:44 +10:30
pm47
557db43378 make htlc outputs of the commitment tx spendable with revocation key
(Merge conflict in test vectors fixed by selecting Pierre's, will have to
 be re-evaluated).

Closes: #105
2017-03-07 09:21:40 +10:30
Rusty Russell
034c234829 BOLT 2,3: SHOULD NOT create malleable funding tx.
But note that our funding transaction example is.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-07 06:39:28 +10:30
Rusty Russell
dc0b529161 BOLT 3: update test vectors for ec99f893f3
The weights of HTLCs were corrected by Pierre in "fixed htlc weight
calculation": this adjusts the test vectors to match.

This also means that the feerate thresholds change.

In addition, this fixes feerate on "maximum feerate" tests,
and corrects the fee for the htlc-timeout tx.

Reported-by: Fabrice Drouin <fabrice.drouin@acinq.fr>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-22 09:59:37 +10:30
Rusty Russell
0801f05795 BOLT 3: Note the HTLC number when annotating witness scripts.
This is more distinctive than amount.

No normative changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-22 09:59:37 +10:30
Rusty Russell
394da29189 BOLT 3: fix test vector derivation.
The test vectors themselves were fine, but they're supposed to be derived
from known basepoints (and I was actually testing this with some new code).

I accidentally used the *remote* per-commitment-point, instead of the *local*
per-commitment-point to derive the remotekey/remote_privkey; since we are
generating the local transaction, this is wrong.  We don't need to know
the remote per-commitment-point at all, in fact.

Thus, the remotekey (and signatures) in the test vectors change.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-22 09:59:37 +10:30
pm47
ec99f893f3 fixed htlc weight calculation 2017-02-10 11:33:41 +10:30
Rusty Russell
fb5e8667bb bolt3 fix and enhance tx testvectors (#99)
This is a smerge of Fabrice Drouin and my work: he update them, I updated them and enhanced them, he found bugs, I re-derived them, etc.

- rename keys properly
- fix fees
- sign all transactions
- Derive test transaction vectors from minimal subset of parameters.
- rewrite test vectors to test edge cases for trimming.
- add funding tx test vector, make testable on regtest.

This adds a funding transaction test (really, we only specify the output), but importantly adds enough information to duplicate a blockchain with that particular funding tx:

$ rm -rf ~/.bitcoin/regtest/
$ bitcoind -regtest=1 &
$ bitcoin-cli -regtest=1 submitblock  0000002006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910fadbb20ea41a8423ea937e76e8151636bf6093b70eaff942930d20576600521fdc30f9858ffff7f20000000000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0100f2052a010000001976a9143ca33c2e4446f4a305f23c80df8ad1afdcf652f988ac00000000
$ bitcoin-cli -regtest=1 generate 431
$ bitcoin-cli -regtest=1 sendrawtransaction 0200000001adbb20ea41a8423ea937e76e8151636bf6093b70eaff942930d20576600521fd000000006b48304502210090587b6201e166ad6af0227d3036a9454223d49a1f11839c1a362184340ef0240220577f7cd5cca78719405cbf1de7414ac027f0239ef6e214c90fcaab0454d84b3b012103535b32d5eb0a6ed0982a0479bbadc9868d9836f6ba94dd5a63be16d875069184ffffffff028096980000000000220020c015c4a6be010e21657068fc2e6a9d02b27ebe4d490a25846f7237f104d1a3cd20256d29010000001600143ca33c2e4446f4a305f23c80df8ad1afdcf652f900000000

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 11:15:33 +10:30
Rusty Russell
0dd1d383ed BOLT 3: fix trimming typo.
If the htlc amount, after htlc fee is *subtracted*, is less than the dust limit,
trim it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-01 12:42:04 +10:30
Rusty Russell
d907eacbac BOLT 3: use P2WPKH instead of P2PKH.
Not only is it shorter and cheaper, but the rest of the document (including
test vectors and weight calculation) assumed it already.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-31 13:09:53 +10:30
Rusty Russell
76937db387 BOLT 3: minor cleanup.
Remove redundant sentence about commitment txin; it's specified exactly
3 lines later.

Refer to the Commitment Transaction section in "Commitment Transaction
Construction".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-25 16:05:11 +10:30
Rusty Russell
de8be3072d BOLT 3: Spell out how to construct the commitment transaction.
* I add the term "trimmed outputs" for sub-dust outputs; this matters
  for both fee calculation and transaction construction.

* Introduce the concept of "base fee": this is what needs to be
  extracted from the funder.

* The requirements are spread between the different sections, let's
  tie it together in a new section at the end.

* Spell out all the steps in the example which calculates fees.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-25 06:23:28 +10:30
Rusty Russell
1819ff9355 BOLT 3: dust-limit should be dust-limit-satoshis
That's the name of the field in BOLT 2.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-25 06:23:28 +10:30
Rusty Russell
b29269419a BOLT 3: Fix amounts in example.
Since we changed from / 1024 to / 1000 in fddc992b2d, the example is
out-of-date.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-25 06:23:28 +10:30
Rusty Russell
30e0cc6782 BOLT 3: Fix one-letter URL typo.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-24 06:55:45 +10:30
Rusty Russell
6aaa9322a1 BOLT 3: Add test vectors for key derivation. (#83)
* BOLT 3: Add test vectors for key derivation.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-24 06:52:29 +10:30
Rusty Russell
fddc992b2d BOLT 2, BOLT 3: fee-per-kw kilo == 1000, not 1024.
I checked the bitcoin source to be sure, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-22 16:17:30 -08:00
Christopher Jämthagen
f1eaa25446 BOLT 3: Use 0x20 as high byte for locktime in commitment transaction
The most significant byte of the locktime in a commitment transaction
must be set to 0x20. This is to make sure that the locktime value
is always higher than 500,000,000, making it interpreted as a Unix
epoch timestamp, and not a block height. It also makes sure that the
locktime is below the current time, allowing the commitment transaction
to be included in a block.

Since the sequence field in the input of the commitment transaction is
used for the other half of the obscured commitment transaction number,
it will never assume the maxInt value (0xFFFFFFFF) which would disable
locktime checking.
2017-01-13 22:57:14 +01:00
Christopher Jämthagen
2045d6d632 witnessScript is part of witness + null dummy for OP_CHECKMULTISIG (#70)
* Add null dummy consumed by OP_CHECKMULTISIG
* scriptsig -> witness.
* witness script -> witness.
2017-01-04 16:09:18 +10:30
pm47
7751ee11f2 added test vectors for transactions 2017-01-04 15:55:41 +10:30
pm47
2c4cd03b4c added a section about who pays the fee 2017-01-04 15:55:41 +10:30
pm47
4339f033e6 moved weight computation to Appendix section, fixed index 2017-01-04 15:55:41 +10:30
Pierre-Marie Padiou
856331e347 fixed numbering 2016-12-21 11:44:15 +01:00
Fabrice Drouin
d02681a53b BOLT 3: fix fee computations
1. HTLC must be able to pay for their HTLC success/timeout transaction fees
2. add examples
2016-12-21 14:55:26 +10:30
Pierre-Marie Padiou
bf68c6253e fixed typo 2016-12-20 19:00:58 +01:00
pm47
951fe14775 added a table of contents to bolt3 2016-12-20 16:43:08 +01:00
fivepiece
66ffc6c624 BOLT 3: Fix funding output script
remove `0` from the funding output script as it is not part of a normal 2-of-2 multisig script
2016-12-18 10:36:49 +10:30
pm47
93f948cbd9 typos and consistency 2016-12-13 15:44:14 +01:00
Rusty Russell
125b9a3657 BOLT 3: Fix commitment transaction input sequence number.
From BIP 68:

	If bit (1 << 31) of the sequence number is set, then no consensus
	meaning is applied to the sequence number and can be included in any
	block under all currently possible circumstances.

Which is what we want.

Reported-by: Olaoluwa Osuntokun <laolu32@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-12-12 11:13:29 +10:30
Rusty Russell
2f998f3741 BOLT 3: make upper bits of commit tx locktime and sequence explicit.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-12-12 10:38:10 +10:30
Christopher Jämthagen
f8f5fa6312 Make it clear that lower 24 bits of locktime is lower 24 bits of the obscured commitment transaction number 2016-12-12 10:37:45 +10:30
Christian Decker
3378afe028 trivial: Consolidating inline code
Now using `<>` on inline code only when part of a script and extra
emphasis is warranted. Outside of scripts the variable names are
already highlighted, so no need to add further emphasis.
2016-12-11 11:08:53 +10:30
Christian Decker
71514b92df trivial: Minor markup fixes 2016-12-11 11:08:53 +10:30
Christopher Jämthagen
6e4f7f0cc2 Consistently use 'transaction' instead of 'tx' 2016-12-09 10:41:48 +01:00
Rusty Russell
e6faf71c30 BOLT 3: Add test vectors for per-commitment-secret generation
These were generated (and recovery tested) by the command-line tool at:

	https://github.com/rustyrussell/ccan/tree/master/ccan/crypto/shachain/tools

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-12-08 11:00:05 +10:30