Skip to content

Modify test to show that update_witnesses may disrupt LN channel operations #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions tests/transfers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,11 @@ fn accept_0conf() {
);
}

#[test]
fn ln_transfers() {
#[rstest]
#[case(false)]
#[ignore = "fix needed"] // https://github.com/RGB-WG/rgb-std/issues/292
#[case(true)]
fn ln_transfers(#[case] update_witnesses_before_htlc: bool) {
initialize();

let mut wlt_1 = get_wallet(&DescriptorType::Wpkh);
Expand Down Expand Up @@ -787,6 +790,9 @@ fn ln_transfers() {
let htlc_btc_amt = 4000;
let htlc_derived_addr = wlt_1.get_derived_address();

// no problem: since there's no htlc for this commitment
wlt_1.sync_and_update_witnesses(Some(pre_funding_height));

println!("\n2. fake commitment TX (1 HTLC)");
let beneficiaries = vec![
(wlt_2.get_address(), Some(2000)),
Expand All @@ -811,6 +817,10 @@ fn ln_transfers() {
wlt_1.consume_fascia(fascia.clone(), psbt.txid());
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);

if update_witnesses_before_htlc {
wlt_1.sync_and_update_witnesses(Some(pre_funding_height));
}

println!("\n3. fake HTLC TX");
let witness_id = fascia.witness_id();
let txid = witness_id.as_reduced_unsafe();
Expand Down Expand Up @@ -887,6 +897,10 @@ fn ln_transfers() {
wlt_1.consume_fascia(fascia.clone(), psbt.txid());
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);

if update_witnesses_before_htlc {
wlt_1.sync_and_update_witnesses(Some(pre_funding_height));
}

println!("\n6. fake HTLC TX");
let witness_id = fascia.witness_id();
let txid = witness_id.as_reduced_unsafe();
Expand Down Expand Up @@ -914,6 +928,9 @@ fn ln_transfers() {
wlt_1.consume_fascia(fascia.clone(), psbt.txid());
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);

// no problem: since the force-close tx will be updated to mined soon
wlt_1.sync_and_update_witnesses(Some(pre_funding_height));

println!("\n7. broadcast old PSBT");
let tx = wlt_1.sign_finalize_extract(&mut old_psbt);
wlt_1.broadcast_tx(&tx);
Expand Down
Loading