Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
jbesraa committed Jul 3, 2024
1 parent 52464d8 commit 1edab3b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/payment/payjoin/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,23 @@ impl PayjoinSender {
) {
let (index, tx) = txdata[0];
let txid = tx.txid();
let mut transactions = self.transactions.lock().unwrap();
let position = transactions.iter().position(|o| o.txid() == Some(txid)).unwrap();
let pj_tx = transactions.remove(position);
let position = self.transactions.lock().unwrap().iter().position(|o| o.txid() == Some(txid)).unwrap();
let pj_tx = self.transactions.lock().unwrap().remove(position);
dbg!("found confirmed", &pj_tx);
let pj_tx = match pj_tx {
PayjoinTransaction::PendingFirstConfirmation {
ref tx,
first_broadcast_height,
first_broadcast_hash,
} => transactions.push(PayjoinTransaction::PendingThresholdConfirmations {
} => {
dbg!("Here in peding first confirmation");
self.transactions.lock().unwrap().push(PayjoinTransaction::PendingThresholdConfirmations {
tx: tx.clone(),
first_broadcast_height,
first_broadcast_hash,
latest_confirmation_height: height,
latest_confirmation_hash: header.block_hash(),
}),
})},
PayjoinTransaction::PendingThresholdConfirmations {
ref tx,
first_broadcast_height,
Expand All @@ -159,7 +160,7 @@ impl PayjoinSender {
if height - first_broadcast_height >= ANTI_REORG_DELAY {
let _ = self.event_queue.add_event(Event::PayjoinTxSendSuccess { txid });
} else {
transactions.push(PayjoinTransaction::PendingThresholdConfirmations {
self.transactions.lock().unwrap().push(PayjoinTransaction::PendingThresholdConfirmations {
tx: tx.clone(),
first_broadcast_height,
first_broadcast_hash,
Expand Down
4 changes: 3 additions & 1 deletion tests/integration_tests_payjoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ fn send_receive_regular_payjoin_transaction() {
assert!(sender_payjoin_payment.send(payjoin_uri).is_ok());
let txid = expect_payjoin_payment_pending_event!(node_b_pj_sender);
wait_for_tx(&electrsd.client, txid);
generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 6);
generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 1);
node_b_pj_sender.sync_wallets().unwrap();
generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 5);
node_b_pj_sender.sync_wallets().unwrap();
// expect_payjoin_payment_success_event!(node_b_pj_sender);
let node_b_balance = node_b_pj_sender.list_balances();
Expand Down

0 comments on commit 1edab3b

Please sign in to comment.