Merge #1321: Deserialize error from create_spend http response

b73193ae77dccde519d43e5042324742dbee5523 Deserialize error from create_spend http response (edouardparis)

Pull request description:

  Instead of having an unclear and ugly message like:
  data did not match any variant of untagged enum DraftPsbtResult

ACKs for top commit:
  edouardparis:
    Self-ACK b73193ae77dccde519d43e5042324742dbee5523

Tree-SHA512: 8182c01ce4067b30dc821dc8f13243b3df4a85fa8f146d779bd9922fedd26f0eabd7fca07c47fdc517b0d958cbe0185c7003e09d6d28f32312e6cb4d4fb9ba52
This commit is contained in:
edouardparis 2024-09-11 13:22:22 +02:00
commit 2a407013e3
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
2 changed files with 12 additions and 0 deletions

View File

@ -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>,

View File

@ -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))
}
}
}