Skip to content

Commit

Permalink
Import swapcoin addresses in taker protocol
Browse files Browse the repository at this point in the history
Previously taker wouldnt do this. I didn't notice because until now
I mostly tested with all the instances connecting to the same regtest
node.
  • Loading branch information
chris-belcher committed Jun 8, 2022
1 parent 229ab43 commit 6176d12
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/taker_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,20 @@ async fn send_coinswap(

if is_taker_next_peer {
incoming_swapcoins = create_incoming_swapcoins(
rpc,
&wallet,
&maker_sign_sender_and_receiver_contracts,
&funding_txes,
&funding_tx_merkleproofs,
&next_swap_contract_redeemscripts,
&next_peer_hashlock_keys_or_nonces,
&next_peer_multisig_pubkeys,
&next_peer_multisig_keys_or_nonces,
preimage,
)
.unwrap();
//TODO reason about why this unwrap is here without any error handling
//do we expect this to never error? are the conditions checked earlier?
}
this_maker_multisig_privkeys = next_peer_multisig_keys_or_nonces;
this_maker_hashlock_privkeys = next_peer_hashlock_keys_or_nonces;
Expand Down Expand Up @@ -1359,8 +1364,11 @@ fn create_watch_only_swapcoins(
}

fn create_incoming_swapcoins(
rpc: &Client,
wallet: &Wallet,
maker_sign_sender_and_receiver_contracts: &SignSendersAndReceiversContractTxes,
funding_txes: &[Transaction],
funding_tx_merkleproofs: &[String],
next_swap_contract_redeemscripts: &[Script],
next_peer_hashlock_keys_or_nonces: &[SecretKey],
next_peer_multisig_pubkeys: &[PublicKey],
Expand Down Expand Up @@ -1416,6 +1424,8 @@ fn create_incoming_swapcoins(
next_contract_redeemscript,
&hashlock_privkey,
&maker_funding_tx_value,
funding_tx,
funding_tx_merkleproof,
) in izip!(
next_swap_multisig_redeemscripts.iter(),
next_peer_multisig_pubkeys.iter(),
Expand All @@ -1424,6 +1434,8 @@ fn create_incoming_swapcoins(
next_swap_contract_redeemscripts.iter(),
next_peer_hashlock_keys_or_nonces.iter(),
last_makers_funding_tx_values.iter(),
funding_txes.iter(),
funding_tx_merkleproofs.iter(),
) {
let (o_ms_pubkey1, o_ms_pubkey2) =
read_pubkeys_from_multisig_redeemscript(multisig_redeemscript)
Expand All @@ -1437,6 +1449,9 @@ fn create_incoming_swapcoins(
o_ms_pubkey1
};

wallet.import_wallet_multisig_redeemscript(&rpc, &o_ms_pubkey1, &o_ms_pubkey2)?;
wallet.import_tx_with_merkleproof(&rpc, funding_tx, funding_tx_merkleproof.clone())?;

let mut incoming_swapcoin = IncomingSwapCoin::new(
maker_funded_multisig_privkey,
maker_funded_other_multisig_pubkey,
Expand Down

0 comments on commit 6176d12

Please sign in to comment.