From d841f2a88f6af94655e042d6411a1ebaf5d4d923 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Wed, 15 Nov 2023 13:27:58 -0600 Subject: [PATCH] Change Signer::sign_tx_input to Signer::sign_psbt_input With the previous API, signing taproot inputs comes with a lot of problems. Taproot signatures commit to the previous txo of all the inputs so to be able to construct a signature, you need to have all of them available. The previous API would require the user to look up the outputs themself which does not really work for mobile clients and it is a bad practice. This changes it to a PSBT so we can give all the necessary info to the user directly. --- bitcoin-rpc-provider/src/lib.rs | 40 ++++++++-- dlc-manager/src/contract_updater.rs | 116 ++++++++++++++++------------ dlc-manager/src/lib.rs | 7 +- mocks/src/mock_wallet.rs | 11 ++- simple-wallet/src/lib.rs | 45 +++++++++-- 5 files changed, 144 insertions(+), 75 deletions(-) diff --git a/bitcoin-rpc-provider/src/lib.rs b/bitcoin-rpc-provider/src/lib.rs index b8153ba5..bbee24c9 100644 --- a/bitcoin-rpc-provider/src/lib.rs +++ b/bitcoin-rpc-provider/src/lib.rs @@ -7,6 +7,7 @@ use std::sync::{Arc, Mutex}; use std::time::Duration; use bitcoin::consensus::encode::Error as EncodeError; +use bitcoin::psbt::PartiallySignedTransaction; use bitcoin::secp256k1::rand::thread_rng; use bitcoin::secp256k1::{PublicKey, SecretKey}; use bitcoin::{ @@ -185,14 +186,35 @@ impl Signer for BitcoinCoreProvider { Ok(pk.inner) } - fn sign_tx_input( + fn sign_psbt_input( &self, - tx: &mut Transaction, + psbt: &mut PartiallySignedTransaction, input_index: usize, - tx_out: &TxOut, - redeem_script: Option