feat: add json_serialize method on psbt type
This commit is contained in:
parent
5ef2bf8a1e
commit
093eb1fc7e
1
bdk-ffi/Cargo.lock
generated
1
bdk-ffi/Cargo.lock
generated
@ -165,6 +165,7 @@ dependencies = [
|
|||||||
"bdk_esplora",
|
"bdk_esplora",
|
||||||
"bdk_file_store",
|
"bdk_file_store",
|
||||||
"bitcoin-internals",
|
"bitcoin-internals",
|
||||||
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"uniffi",
|
"uniffi",
|
||||||
]
|
]
|
||||||
|
@ -26,6 +26,7 @@ bdk_file_store = { version = "0.11.0" }
|
|||||||
uniffi = { version = "=0.27.1" }
|
uniffi = { version = "=0.27.1" }
|
||||||
bitcoin-internals = { version = "0.2.0", features = ["alloc"] }
|
bitcoin-internals = { version = "0.2.0", features = ["alloc"] }
|
||||||
thiserror = "1.0.58"
|
thiserror = "1.0.58"
|
||||||
|
serde_json = "1.0.116"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
uniffi = { version = "=0.27.1", features = ["build"] }
|
uniffi = { version = "=0.27.1", features = ["build"] }
|
||||||
|
@ -657,6 +657,11 @@ interface Psbt {
|
|||||||
|
|
||||||
[Throws=PsbtError]
|
[Throws=PsbtError]
|
||||||
u64 fee();
|
u64 fee();
|
||||||
|
|
||||||
|
[Throws=PsbtError]
|
||||||
|
Psbt combine(Psbt other);
|
||||||
|
|
||||||
|
string json_serialize();
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary OutPoint {
|
dictionary OutPoint {
|
||||||
|
@ -18,6 +18,7 @@ use bdk::bitcoin::TxIn as BdkTxIn;
|
|||||||
use bdk::bitcoin::Txid;
|
use bdk::bitcoin::Txid;
|
||||||
|
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
use std::ops::Deref;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
@ -230,19 +231,20 @@ impl Psbt {
|
|||||||
.map_err(PsbtError::from)
|
.map_err(PsbtError::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
pub(crate) fn combine(
|
||||||
// pub(crate) fn combine(
|
&self,
|
||||||
// &self,
|
other: Arc<Psbt>,
|
||||||
// other: Arc<Psbt>,
|
) -> Result<Arc<Psbt>, PsbtError> {
|
||||||
// ) -> Result<Arc<Psbt>, > {
|
let mut original_psbt = self.0.lock().unwrap().clone();
|
||||||
// let other_psbt = other.inner.lock().unwrap().clone();
|
let other_psbt = other.0.lock().unwrap().clone();
|
||||||
// let mut original_psbt = self.inner.lock().unwrap().clone();
|
original_psbt.combine(other_psbt)?;
|
||||||
//
|
Ok(Arc::new(Psbt(Mutex::new(original_psbt))))
|
||||||
// original_psbt.combine(other_psbt)?;
|
}
|
||||||
// Ok(Arc::new(PartiallySignedTransaction {
|
|
||||||
// inner: Mutex::new(original_psbt),
|
pub(crate) fn json_serialize(&self) -> String {
|
||||||
// }))
|
let psbt = self.0.lock().unwrap();
|
||||||
// }
|
serde_json::to_string(psbt.deref()).unwrap()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<BdkPsbt> for Psbt {
|
impl From<BdkPsbt> for Psbt {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user