feat: support outpoints recovery parameter
This changes the GUI daemon trait's create_recovery method to support passing an outpoints parameter. For now, however, this method is called with an empty outpoints slice, meaning that all recoverable coins will be used.
This commit is contained in:
parent
0ff3479d56
commit
71541c69ba
@ -156,7 +156,7 @@ impl State for RecoveryPanel {
|
||||
return Task::perform(
|
||||
async move {
|
||||
let psbt = daemon
|
||||
.create_recovery(address, feerate_vb, sequence)
|
||||
.create_recovery(address, &[], feerate_vb, sequence)
|
||||
.await?;
|
||||
let outpoints: Vec<_> = psbt
|
||||
.unsigned_tx
|
||||
|
||||
@ -182,12 +182,13 @@ impl<C: Client + Send + Sync + Debug> Daemon for Lianad<C> {
|
||||
async fn create_recovery(
|
||||
&self,
|
||||
address: Address<address::NetworkUnchecked>,
|
||||
coins_outpoints: &[OutPoint],
|
||||
feerate_vb: u64,
|
||||
sequence: Option<u16>,
|
||||
) -> Result<Psbt, DaemonError> {
|
||||
// The `outpoints` parameter is omitted, which means all recoverable coins will be used.
|
||||
let mut params = serde_json::Map::new();
|
||||
params.insert("address".to_string(), json!(address));
|
||||
params.insert("outpoints".to_string(), json!(coins_outpoints));
|
||||
params.insert("feerate".to_string(), json!(feerate_vb));
|
||||
if let Some(sequence) = sequence {
|
||||
params.insert("timelock".to_string(), json!(sequence));
|
||||
|
||||
@ -212,12 +212,13 @@ impl Daemon for EmbeddedDaemon {
|
||||
async fn create_recovery(
|
||||
&self,
|
||||
address: Address<address::NetworkUnchecked>,
|
||||
coins_outpoints: &[OutPoint],
|
||||
feerate_vb: u64,
|
||||
sequence: Option<u16>,
|
||||
) -> Result<Psbt, DaemonError> {
|
||||
self.command(|daemon| {
|
||||
daemon
|
||||
.create_recovery(address, &[], feerate_vb, sequence)
|
||||
.create_recovery(address, coins_outpoints, feerate_vb, sequence)
|
||||
.map(|res| res.psbt)
|
||||
.map_err(|e| DaemonError::Unexpected(e.to_string()))
|
||||
})
|
||||
|
||||
@ -138,6 +138,7 @@ pub trait Daemon: Debug {
|
||||
async fn create_recovery(
|
||||
&self,
|
||||
address: Address<address::NetworkUnchecked>,
|
||||
coins_outpoints: &[OutPoint],
|
||||
feerate_vb: u64,
|
||||
sequence: Option<u16>,
|
||||
) -> Result<Psbt, DaemonError>;
|
||||
|
||||
@ -418,9 +418,12 @@ pub mod payload {
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct GenerateRecoveryPsbt {
|
||||
pub struct GenerateRecoveryPsbt<'a> {
|
||||
/// The address to sweep funds to.
|
||||
pub address: bitcoin::Address<bitcoin::address::NetworkUnchecked>,
|
||||
/// The outpoints of coins to use as transaction inputs. If empty, all
|
||||
/// coins that are recoverable on the chosen recovery path will be used.
|
||||
pub inputs: &'a [bitcoin::OutPoint],
|
||||
// The feerate to use for this transaction.
|
||||
pub feerate: u64,
|
||||
/// Timelock of the recovery path to use.
|
||||
|
||||
@ -912,6 +912,7 @@ impl Daemon for BackendWalletClient {
|
||||
async fn create_recovery(
|
||||
&self,
|
||||
address: Address<address::NetworkUnchecked>,
|
||||
coins_outpoints: &[OutPoint],
|
||||
feerate_vb: u64,
|
||||
sequence: Option<u16>,
|
||||
) -> Result<Psbt, DaemonError> {
|
||||
@ -931,6 +932,7 @@ impl Daemon for BackendWalletClient {
|
||||
timelock: sequence
|
||||
.ok_or(DaemonError::Unexpected("Missing sequence".to_string()))?,
|
||||
address,
|
||||
inputs: coins_outpoints,
|
||||
})
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user