From 9b4b450e88d48f5a8e7dd511bb637b3a856c9f86 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Mon, 18 Dec 2023 13:50:16 -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 | 37 +++++++-- dlc-manager/src/channel_updater.rs | 12 ++- dlc-manager/src/contract_updater.rs | 118 ++++++++++++++++------------ dlc-manager/src/lib.rs | 7 +- dlc-manager/src/manager.rs | 4 +- mocks/src/mock_wallet.rs | 11 ++- simple-wallet/src/lib.rs | 45 +++++++++-- 7 files changed, 153 insertions(+), 81 deletions(-) diff --git a/bitcoin-rpc-provider/src/lib.rs b/bitcoin-rpc-provider/src/lib.rs index b8153ba5..413b2903 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,32 @@ 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