Skip to content

Commit

Permalink
fix: wrong to address cannot be traded when appelt is not upgraded
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoguang1010 committed Sep 26, 2024
1 parent dbb88e0 commit eccdf94
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions imkey-core/ikc-wallet/coin-bitcoin/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,28 @@ impl BtcTransaction {
};
}
} else {
if BTC_SEG_WIT_TYPE_P2WPKH.eq(&seg_wit.to_uppercase()) {
self.original_tx_preview(&tx_to_sign, network)?;
for (idx, _) in self.unspents.iter().enumerate() {
self.sign_p2sh_nested_p2wpkh_input(
idx,
&utxo_pub_key_vec[idx],
&mut tx_to_sign,
)?;
}
} else {
self.tx_preview(&tx_to_sign, network)?;
self.sign_p2pkh_inputs(&utxo_pub_key_vec, &mut tx_to_sign)?;
let address_version = get_address_version(network, &self.to.to_string())?;
match address_version {
0 | 111 | 5 | 96 =>{
if BTC_SEG_WIT_TYPE_P2WPKH.eq(&seg_wit.to_uppercase()) {
self.original_tx_preview(&tx_to_sign, network)?;
for (idx, _) in self.unspents.iter().enumerate() {
self.sign_p2sh_nested_p2wpkh_input(
idx,
&utxo_pub_key_vec[idx],
&mut tx_to_sign,
)?;
}
} else {
self.tx_preview(&tx_to_sign, network)?;
self.sign_p2pkh_inputs(&utxo_pub_key_vec, &mut tx_to_sign)?;
}
},
_ => {
return Err(CoinError::InvalidAddress.into());
},
}

}

let tx_bytes = serialize(&tx_to_sign);
Expand Down

0 comments on commit eccdf94

Please sign in to comment.