Skip to content

Commit 11610af

Browse files
committed
Derive FundingContribution::net_value implicitly
This commit removes `FundingContribution::value_added` as tracking it is unnecessary -- it can just be derived from the total amount in minus total amount out minus fees.
1 parent 41a2baa commit 11610af

3 files changed

Lines changed: 98 additions & 398 deletions

File tree

fuzz/src/full_stack.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,8 +1886,8 @@ fn splice_seed() -> Vec<u8> {
18861886
// CommitmentSigned message with proper signature (r=f7, s=01...) and funding_txid TLV
18871887
// signature r encodes sighash first byte f7, s follows the pattern from funding_created
18881888
// TLV type 1 (odd/optional) for funding_txid as per impl_writeable_msg!(CommitmentSigned, ...)
1889-
// Note: txid is encoded in reverse byte order (Bitcoin standard), so to get display 0000...0033, encode 3300...0000
1890-
ext_from_hex("0084 c000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000f7 0100000000000000000000000000000000000000000000000000000000000000 0000 01 20 3300000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
1889+
// Note: txid is encoded in reverse byte order (Bitcoin standard), so to get display 0000...0031, encode 3100...0000
1890+
ext_from_hex("0084 c000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000f7 0100000000000000000000000000000000000000000000000000000000000000 0000 01 20 3100000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
18911891

18921892
// After commitment_signed exchange, we need to exchange tx_signatures.
18931893
// Message type IDs: TxSignatures = 71 (0x0047)
@@ -1900,19 +1900,19 @@ fn splice_seed() -> Vec<u8> {
19001900
// inbound read from peer id 0 of len 150 (134 message + 16 MAC)
19011901
ext_from_hex("030096", &mut test);
19021902
// TxSignatures message with shared_input_signature TLV (type 0)
1903-
// txid must match the splice funding txid (0x33 in reverse byte order)
1903+
// txid must match the splice funding txid (0x31 in reverse byte order)
19041904
// shared_input_signature: 64-byte fuzz signature for the shared input
1905-
ext_from_hex("0047 c000000000000000000000000000000000000000000000000000000000000000 3300000000000000000000000000000000000000000000000000000000000000 0000 00 40 00000000000000000000000000000000000000000000000000000000000000dc 0100000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
1905+
ext_from_hex("0047 c000000000000000000000000000000000000000000000000000000000000000 3100000000000000000000000000000000000000000000000000000000000000 0000 00 40 00000000000000000000000000000000000000000000000000000000000000dc 0100000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
19061906

19071907
// Connect a block with the splice funding transaction to confirm it
19081908
// The splice funding tx: version(4) + input_count(1) + txid(32) + vout(4) + script_len(1) + sequence(4)
19091909
// + output_count(1) + value(8) + script_len(1) + script(34) + locktime(4) = 94 bytes = 0x5e
19101910
// Transaction structure from FundingTransactionReadyForSigning:
19111911
// - Input: spending c000...00:0 with sequence 0xfffffffd
1912-
// - Output: 115536 sats to OP_0 PUSH32 6e00...00
1912+
// - Output: 115538 sats to OP_0 PUSH32 6e00...00
19131913
// - Locktime: 13
19141914
ext_from_hex("0c005e", &mut test);
1915-
ext_from_hex("02000000 01 c000000000000000000000000000000000000000000000000000000000000000 00000000 00 fdffffff 01 50c3010000000000 22 00206e00000000000000000000000000000000000000000000000000000000000000 0d000000", &mut test);
1915+
ext_from_hex("02000000 01 c000000000000000000000000000000000000000000000000000000000000000 00000000 00 fdffffff 01 52c3010000000000 22 00206e00000000000000000000000000000000000000000000000000000000000000 0d000000", &mut test);
19161916

19171917
// Connect additional blocks to reach minimum_depth confirmations
19181918
for _ in 0..5 {
@@ -1929,8 +1929,8 @@ fn splice_seed() -> Vec<u8> {
19291929
// inbound read from peer id 0 of len 82 (66 message + 16 MAC)
19301930
ext_from_hex("030052", &mut test);
19311931
// SpliceLocked message (type 77 = 0x004d): channel_id + splice_txid + mac
1932-
// splice_txid must match the splice funding txid (0x33 in reverse byte order)
1933-
ext_from_hex("004d c000000000000000000000000000000000000000000000000000000000000000 3300000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
1932+
// splice_txid must match the splice funding txid (0x31 in reverse byte order)
1933+
ext_from_hex("004d c000000000000000000000000000000000000000000000000000000000000000 3100000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
19341934

19351935
test
19361936
}
@@ -2060,6 +2060,6 @@ mod tests {
20602060

20612061
// Splice locked
20622062
assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling SendSpliceLocked event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 for channel c000000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&1));
2063-
assert_eq!(log_entries.get(&("lightning::ln::channel".to_string(), "Promoting splice funding txid 0000000000000000000000000000000000000000000000000000000000000033".to_string())), Some(&1));
2063+
assert_eq!(log_entries.get(&("lightning::ln::channel".to_string(), "Promoting splice funding txid 0000000000000000000000000000000000000000000000000000000000000031".to_string())), Some(&1));
20642064
}
20652065
}

0 commit comments

Comments
 (0)