From 113db340a345ccadf35d236aa9d25a826550d5f5 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Sun, 12 Dec 2021 18:51:49 +0100 Subject: [PATCH] bitcoind: remove needless call to 'finalizepsbt' --- src/daemon/bitcoind/interface.rs | 26 +++++++------------------- src/daemon/bitcoind/poller.rs | 1 - 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/daemon/bitcoind/interface.rs b/src/daemon/bitcoind/interface.rs index ab649dcd..2c33a26c 100644 --- a/src/daemon/bitcoind/interface.rs +++ b/src/daemon/bitcoind/interface.rs @@ -2,12 +2,9 @@ use crate::common::config::BitcoindConfig; use crate::daemon::{bitcoind::BitcoindError, revaultd::BlockchainTip}; use revault_tx::{ bitcoin::{ - blockdata::constants::COIN_VALUE, - consensus::{encode, Decodable}, - hashes::hex::FromHex, - util::bip32::ChildNumber, - util::psbt::PartiallySignedTransaction as Psbt, - Amount, BlockHash, OutPoint, Script, Transaction, TxOut, Txid, + blockdata::constants::COIN_VALUE, consensus::encode, util::bip32::ChildNumber, + util::psbt::PartiallySignedTransaction as Psbt, Amount, BlockHash, OutPoint, Script, + Transaction, TxOut, Txid, }, transactions::{DUST_LIMIT, UNVAULT_CPFP_VALUE}, }; @@ -718,6 +715,10 @@ impl BitcoinD { }) } + /// Make bitcoind: + /// 1. Add information to the PSBT inputs + /// 2. Sign the PSBT inputs it can + /// 3. Finalize the PSBT if it is complete pub fn sign_psbt(&self, psbt: &Psbt) -> Result<(bool, Psbt), BitcoindError> { let res = self.make_cpfp_request( "walletprocesspsbt", @@ -740,19 +741,6 @@ impl BitcoinD { Ok((complete, psbt)) } - pub fn finalize_psbt(&self, psbt: String) -> Result { - let res = self.make_cpfp_request("finalizepsbt", ¶ms!(Json::String(psbt)))?; - let hex_str = res - .get("hex") - .expect("API break: no 'hex' in 'finalizepsbt' result") - .as_str() - .expect("API break: invalid 'hex' in 'finalizepsbt' result"); - let hex = >::from_hex(hex_str) - .expect("API break: invalid 'hex' in 'finalizepsbt' result"); - Ok(Transaction::consensus_decode(hex.as_slice()) - .expect("API break: invalid 'hex' in 'finalizepsbt' result")) - } - /// Broadcast a transaction with 'sendrawtransaction', discarding the returned txid pub fn broadcast_transaction(&self, tx: &Transaction) -> Result<(), BitcoindError> { let tx_hex = encode::serialize_hex(tx); diff --git a/src/daemon/bitcoind/poller.rs b/src/daemon/bitcoind/poller.rs index a817da13..65035c4b 100644 --- a/src/daemon/bitcoind/poller.rs +++ b/src/daemon/bitcoind/poller.rs @@ -483,7 +483,6 @@ fn cpfp_package( ); return Ok(()); } - let psbt_signed = bitcoind.finalize_psbt(psbt_signed)?; let final_tx = psbt_signed.extract_tx(); if let Err(e) = bitcoind.broadcast_transaction(&final_tx) {