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

148 Commits

Author SHA1 Message Date
Elle Mouton
33098ad37a BOLT 03: fix anchors same amt and pre-image test vector
The `commitment tx with 3 htlc outputs, 2 offered having the same amount
and preimage` test was not correctly updated after the value of test
htlc 6 was changed to 5000001 and the cltv expiry of test htlc 5 was
changed to 506. This commit updates the anchors test accordingly.
2023-02-28 10:51:45 +01:00
Elle Mouton
20066dc2ab BOLT 03: fix static-remote same amt and pre-image test vector
The `commitment tx with 3 htlc outputs, 2 offered having the same amount
and preimage` test was not correctly updated after the value of test
htlc 6 was changed to 5000001 and the cltv expiry of test htlc 5 was
changed to 506. This commit updates the static-remote test accordingly.
2023-02-28 10:51:45 +01:00
Elle Mouton
7f7ee7ffe6 BOLT 03: fix legacy same amt and pre-image test vector
The `commitment tx with 3 htlc outputs, 2 offered having the same amount
and preimage` test was not correctly updated after the value of test
htlc 6 was changed to 5000001 and the cltv expiry of test htlc 5 was
changed to 506. This commit updates the legacy test accordingly.
2023-02-28 10:51:45 +01:00
Elle Mouton
2be691e19d BOLT 03: fix no htlc single anchor test
The commitment transaction tests are all meant to use the same funding
transaction which has an amount of 10000000000 msat. The LocalBalance
and RemoteBalance along with the value of any htlcs should always add up
to this amount.

This commit updates the `simple commitment tx with no HTLCs and single
anchor` anchors test to comply with the above.
2023-02-28 10:51:45 +01:00
Wilmer Paulino
b02bb6b0ed
Add test vectors for option_anchors_zero_fee_htlc_tx (#1018)
These are the same test vectors as those found under Appendix F, except
that each HTLC has a zero fee transaction instead, resulting in a
signature change.
2023-02-28 09:30:50 +01:00
Duncan Dean
f32c6ddb5f
bolt3: Clarify order of operations for HTLC amount calculation (#1020)
The order of operations is now more clearly specified as:

HTLC output amount = (`amount_msat` / 1000) - (fees in satoshis) where all
divisions are rounded down.

This is required to avoid issues in rounding if we were to take
HTLC output amount = (`amount_msat` - (`feerate_per_kw` * weight)) / 1000 and
then rounded down.
2022-08-30 17:21:41 +02:00
Antoni Spaanderman
0c649ea1c2 Update 03-transactions.md 2022-06-10 19:04:36 +02:00
Gregory Sanders
c4a0369e70
Make generated pubkeys slightly more grep-able (#988)
* remotepubkey instead of remote_pubkey
* Add a grepable reference of localpubkey usage
2022-05-12 09:19:21 +02:00
Antoni Spaanderman
2bd5d7e682
Bolt 3: fix broken markdown link (#984) 2022-04-22 13:31:59 +02:00
ziggie1984
71610b06bb
Minor clarification of htlcs to_self_delay (#983)
This is a minor clarification that the `to_self_delay` is enforced
in a 2nd-stage transaction for HTLCs, while it's directly enforced
in the commit tx for the main output.
2022-04-22 09:36:52 +02:00
Ken Sedgwick
d975de1ba5
Clarify the sighash types for HTLC Success and Timeout transactions (#954) 2022-01-31 21:05:20 +01:00
Rusty Russell
4fc9f51889 Update 03-transactions.md
Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2021-12-14 10:32:24 +10:30
Rusty Russell
eb6f3084c5 Make it explicit when to send warnings, errors, fail channel and close connection.
And make most places warn or error.  Places where we're operating
on a channel tend to be "warn and close connection" since we want to
forget the mistake they just sent, and closing the connection does that.

We now use the same words everywhere:
1. "fail channel" means to go onchain (if necessary).
2. "send `error`" means to send an error message.
3. "send `warning`" means to send a warning message.
4. "close connection" means close the connection.

These are all spelled out explicitly, rather than having "fail channel"
imply sending an error packet, for example.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-12-14 10:32:22 +10:30
Bastien Teinturier
8f2104e3b6
Peers need to check each other's dust limit (#894)
Since HTLCs below this amount will not appear in the commitment tx, they
are effectively converted to miner fees. The peer could use this to grief
you by broadcasting its commitment once it contains a lot of dust HTLCs.

Add network dust thresholds computation details, as implemented in Bitcoin
Core's default relay policy.

Drop non-segwit support in shutdown: this allows dust limit to go as low
as 354 sats without creating relay issues with default node policies.

We add a requirement that dust limit cannot be lower than 354 sats.
This ensures implementers don't have to figure this subtlety on their own.

Fixes #696 and #905
2021-10-06 09:40:22 +02:00
Rusty Russell
38abac6206
BOLT 3: add a missing Otherwise, don't SHOULD "be". (#907)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-09-03 08:37:48 +02:00
Johan T. Halseth
fdc078f845
feature: define option_zero_htlc_tx_fee (feature 22/23) (#824)
This PR adds a new feature bit to define the new and improved anchor outputs commitment format.
2021-08-30 13:50:25 -07:00
Matt Corallo
bda72c8305
Concretize Output Ordering to be less confusing (#876)
* Clean up output sorting wording to be a sorted list and way more explicit
* Retitle section to not mention input ordering as we do not need it
2021-06-21 22:14:27 +02:00
Bastien Teinturier
381650c7bc
Clarify Bolt 3 htlc tx output test vectors (#852)
It was sometimes unclear where we indexed by the output or the htlc id.
This is a follow-up from discussions made in #539.
2021-06-21 22:01:47 +02:00
Olaoluwa Osuntokun
46d798e104 BOLT-03: update test vectors w/ updated HTLC tie-breaker case 2021-05-25 06:45:20 +09:30
Olaoluwa Osuntokun
e3362410ac BOLT-03: make sats portion of HTLC CLTV tie-breaker more explicit
This commit is intended to fix an ambiguity in the spec that led to a
divergence in the sorting tie breaker between implementations, that can
lead to force closed transaction in practice. BIP 69 operates on the
output level, therefore it examines the _satoshi_ amount of a output
when sorting. The spec however, references BIP 69, but states that an
"identical" HTLC output may have the same `amount_msat` value.

In the wild this led to some implementations checking the _sat_ value of
an HTLC while others checked the _msat_ value. In the scenario where an
pair HTLC has the same _sat_ value, but differing _msat_ values, then
one will fall through to the tie-breaker, while the other while sort
them according to their _msat_ values.

In this commit, we attempt to make this requirement more explicit by
removing the reference to `msat`, and more explicitly describing when an
HTLC pair is to be considered identical.
2021-05-25 06:45:20 +09:30
araspitzu
b201efe054
BOLT 3: add test vectors for htlc-transactions in case where CLTV is used as tie-breaker for sorting (#539)
Add a serialized transactions test vector for the edge case of sorting htlc-timeout-tx
when there are multiple offered htlc with the same amount and preimage.

The test vector reuses previous preimages and creates a case scenario with 1 received htlc
and 2 offered, the two offered will have same scriptPubKey and redeemScript, but different CLTV value.

It is asserted the order in which the htlc transactions should be kept internally
and we assume the same order is used to construct the commitment_signed message.
This complements #491 .
2021-03-05 09:10:26 +01:00
Dan Gershony
b80f8a7194
Add links to section 9 (anchor outputs) (#833) 2021-01-27 09:12:41 +01:00
Johan T. Halseth
d0c83854de
Correct htlc witness size calculations (#815)
* BOLT#3: use 4 bytes for cltv_expiry in accepted_htlc_script
* BOLT#3: correct success_witness size
* BOLT#3: note HTLC tx weights differ a bit from actual weights
2020-12-07 21:32:29 +01:00
Olaoluwa Osuntokun
c053ce7afb
Merge pull request #688 from joostjager/anchor-outputs
Anchor outputs
2020-08-19 16:41:08 -07:00
Joost Jager
1739746afa
Anchor outputs
This commit extends the specification with a new commitment format that
adds two anchor outputs to the commitment transaction. Anchor outputs
are a safety feature that allows a channel party to unilaterally increase
the fee of the commitment transaction using CPFP and ensure timely
confirmation on the chain. There is no cooperation required from the
remote party.
2020-08-19 15:27:21 +02:00
Rusty Russell
0ac9a6c409
BOLT 3: fix definition of flip(B) in P. (#779)
It turns out everyone does `P[B / 8] ^= (1 << (P % 8))`,
which is not what the spec says to do (it implies you
would treat P as a bitstring numbered 255 to 0).

See this stackoverflow question:
	https://stackoverflow.com/questions/49928131/lightning-secret-generation-from-seed

Reported-by: Janus Troelsen @ysangkok (on Twitter)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-07-07 08:58:08 +02:00
Joost Jager
bfc66e5e4a
Fixes to existing spec 2020-06-26 09:18:49 +02:00
Antoine Riard
11fd658059
Make explicit witness must conform to MINIMALIF (#764) 2020-04-27 21:50:57 +02:00
Bastien Teinturier
dcbf858397
Clarify numerical comparison of pubkeys (#743)
We are using lexixographic order (which is the same as big-endian
when inputs have the same size, such as compressed public keys).
2020-02-18 09:53:12 +01:00
Tim Ruffing
fb7102e034
Remove reference to DER encoding for public keys in compressed format (#742)
ECDSA signatures in Bitcoin are DER-encoded but public keys are not.

The compressed format for public keys is for example standardized in
Sections 2.3.3 and 2.3.4 of

  Standards for Efficient Cryptography, SEC 1: Elliptic Curve
  Cryptography, Certicom Research, Version 2, 2009,
  https://www.secg.org/sec1-v2.pdf
2020-02-17 11:00:30 +01:00
Jan Xie
2afe097f68
Fix a typo in insert_secret pseudo code (#741)
... to make it consistent with the `where_to_put_secret` above.
2020-02-14 09:45:32 +01:00
Rusty Russell
2afe3559e8 option_static_remotekey: final draft.
This separates out the static remotekey changes from the more ambitious
option_simplified_commitment (which also included pushme outputs and
bring-your-own-fee for HTLC outputs).

As per http://www.erisian.com.au/meetbot/lightning-dev/2019/lightning-dev.2019-09-02-20.06.html

Thanks to everyone for feedback: @araspitzu @roasbeef @bitconner

Suggested-by: @roasbeef
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-26 06:19:58 +00:00
Darosior
d669b01ba7 BOLT #3: Use space to indent in key derivation algorithms (#665) 2019-09-05 07:44:38 +00:00
Nadav Kohen
8555709811 BOLT 3: Explicit description of implicitly enforced timelocks on HTLC outputs (#601)
* Added descriptions of how a 2-of-2 multisignature verification is used for enforcing timelocks when timing out on-chain offered HTLCs as well as spending on-chain received HTLCs in the success case.
2019-08-19 21:52:09 +00:00
Alex Bosworth
636b9f2e28 Change opcode reference format (#594)
OP_CHECKLOCKTIMEVERIFY and OP_CSV use an inconsistent naming convention.
Update OP_CSV to match the OP_CHECKLOCKTIMEVERIFY convention as OP_CHECKSEQUENCEVERIFY.
2019-07-09 10:40:29 +02:00
Antoine Riard
6508af5145 Specify OP_DATA to express accepted/offered_htlc_script with same
convention
2019-02-04 23:44:25 +00:00
Orfeas Stefanos Thyfronitis Litos
064d6feed0 Align offered and received HTLC scripts similarly 2019-01-22 21:45:06 +01:00
Rusty Russell
a57ff00e93 BOLT #2: order htlc_signatures by BIP69 + increasing CLTV.
We express it has how the outputs are ordered, but the only way you can
detect that is by the htlc_signatures order, which is the part which really
matters.

I finally reproduced this, BTW, which is why I'm digging it up!

Closes: #448
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-22 21:43:58 +01:00
Antoine Riard
681f3c3621 Fix ambiguity on HTLC transactions spendable by a penalty one
Both HTLC-success/HTLC-timeout can be spent by a valid penalty
transaction
2019-01-15 22:52:30 +00:00
Rusty Russell
af2e94b22d
Merge pull request #529 from nayuta-gondo/pr/20181206a-remote_htlcpubkey
BOLT 3: add description of `remote_htlcpubkey` in `Key Derivation`.
2019-01-07 19:40:57 +00:00
Hiroki Gondo
626fff28c9 BOLT 3: fix the rationale of Closing Transaction. 2019-01-07 19:38:55 +00:00
Hiroki Gondo
eba1c70f6b BOLT 3: fix trivial typo. 2019-01-07 20:18:31 +01:00
Hiroki Gondo
e64c9863b5 BOLT 3: add description of remote_htlcpubkey in Key Derivation. 2018-12-06 21:30:01 +09:00
Hiroki Gondo
56ada3d85c BOLT 3: commitment number not commitment transaction number.
Be consistent.
2018-11-29 04:24:28 +00:00
Orfeas Litos
24d5d33d67 Specify valid signature hash flags (SIGHASH_ALL)
Clarify that this flag is only used for signing and not transmitted
2018-11-29 04:18:04 +00:00
Mykola Sakhno
8e62fd3a08 BOLT 3: fix private key in internal part 2018-11-29 04:17:43 +00:00
Hajime Yamaguchi
a9195a84d0 BOLT 3/BOLT 7: Fix broken links. 2018-08-07 00:07:26 +00:00
Janus Troelsen
5c11b6a402 Fix TOC indentation and links 2018-06-25 10:58:03 +00:00
Carsten Otto
acfd90e009 fix fee calculation numbers 2018-06-11 11:18:16 +00:00
Li Xuanji
a495b3a74f Define P2WSH earlier 2018-04-11 03:42:05 +00:00