Skip to content

Commit

Permalink
rpc_api: Add new test for sign_raw_transaction_with_wallet.
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyhunsen committed Aug 22, 2024
1 parent c6e7479 commit 7a481ab
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/client/rpc_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,4 +786,44 @@ mod tests {
assert_eq!(tx, new_tx);
assert_eq!(res.change_position, -1);
}

#[test]
fn sign_raw_transaction_with_wallet() {
let rpc = Client::new(
"sign_raw_transaction_with_wallet",
bitcoincore_rpc::Auth::None,
)
.unwrap();

let address = Ledger::generate_credential_from_witness().address;
let txid = rpc
.send_to_address(
&address,
Amount::from_sat(0x1F),
None,
None,
None,
None,
None,
None,
)
.unwrap();
let txin = rpc.ledger.create_txin(txid, 0);
let txout = rpc
.ledger
.create_txout(Amount::from_sat(0x45), address.script_pubkey());
let tx = rpc
.ledger
.create_transaction(vec![txin.clone()], vec![txout]);

assert!(txin.witness.is_empty());

let res = rpc
.sign_raw_transaction_with_wallet(&tx, None, None)
.unwrap();
let new_tx = String::consensus_decode(&mut res.hex.as_slice()).unwrap();
let new_tx = decode_from_hex::<Transaction>(new_tx).unwrap();

assert!(!new_tx.input.first().unwrap().witness.is_empty());
}
}

0 comments on commit 7a481ab

Please sign in to comment.