Deserialize error from create_spend http response
Instead of having a simple ugly message like: data did not match any variant of untagged enum DraftPsbtResult
This commit is contained in:
parent
a0bafa4cdc
commit
b73193ae77
@ -284,6 +284,7 @@ pub struct Psbt {
|
||||
pub enum DraftPsbtResult {
|
||||
Success(DraftPsbt),
|
||||
InsufficientFunds(InsufficientFundsInfo),
|
||||
Error(DraftPsbtError),
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize)]
|
||||
@ -291,6 +292,11 @@ pub struct InsufficientFundsInfo {
|
||||
pub missing: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize)]
|
||||
pub struct DraftPsbtError {
|
||||
pub error: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize)]
|
||||
pub struct DraftPsbt {
|
||||
pub uuid: Option<String>,
|
||||
|
||||
@ -753,6 +753,9 @@ impl Daemon for BackendWalletClient {
|
||||
api::DraftPsbtResult::InsufficientFunds(api::InsufficientFundsInfo { missing }) => {
|
||||
Ok(CreateSpendResult::InsufficientFunds { missing })
|
||||
}
|
||||
api::DraftPsbtResult::Error(api::DraftPsbtError { error }) => {
|
||||
Err(DaemonError::Unexpected(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -790,6 +793,9 @@ impl Daemon for BackendWalletClient {
|
||||
api::DraftPsbtResult::InsufficientFunds(api::InsufficientFundsInfo { missing }) => {
|
||||
Ok(CreateSpendResult::InsufficientFunds { missing })
|
||||
}
|
||||
api::DraftPsbtResult::Error(api::DraftPsbtError { error }) => {
|
||||
Err(DaemonError::Unexpected(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user