Add PartiallySignedTransaction.json_serialize() function
This commit is contained in:
parent
478b12c489
commit
fab9ae8ae5
@ -369,6 +369,9 @@ class PartiallySignedTransaction(psbtBase64: String) {
|
||||
* In accordance with BIP 174 this function is commutative i.e., `A.combine(B) == B.combine(A)`
|
||||
*/
|
||||
fun combine(other: PartiallySignedTransaction): PartiallySignedTransaction
|
||||
|
||||
/** Serialize the PSBT data structure as a String of JSON. */
|
||||
fun jsonSerialize(): String
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -307,6 +307,8 @@ interface PartiallySignedTransaction {
|
||||
u64? fee_amount();
|
||||
|
||||
FeeRate? fee_rate();
|
||||
|
||||
string json_serialize();
|
||||
};
|
||||
|
||||
dictionary TxBuilderResult {
|
||||
|
@ -1,6 +1,8 @@
|
||||
use bdk::bitcoin::hashes::hex::ToHex;
|
||||
use bdk::bitcoin::util::psbt::PartiallySignedTransaction as BdkPartiallySignedTransaction;
|
||||
use bdk::bitcoincore_rpc::jsonrpc::serde_json;
|
||||
use bdk::psbt::PsbtUtils;
|
||||
use std::ops::Deref;
|
||||
use std::str::FromStr;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
@ -66,6 +68,12 @@ impl PartiallySignedTransaction {
|
||||
pub(crate) fn fee_rate(&self) -> Option<Arc<FeeRate>> {
|
||||
self.internal.lock().unwrap().fee_rate().map(Arc::new)
|
||||
}
|
||||
|
||||
/// Serialize the PSBT data structure as a String of JSON.
|
||||
pub(crate) fn json_serialize(&self) -> String {
|
||||
let psbt = self.internal.lock().unwrap();
|
||||
serde_json::to_string(psbt.deref()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
// The goal of these tests to to ensure `bdk-ffi` intermediate code correctly calls `bdk` APIs.
|
||||
|
Loading…
x
Reference in New Issue
Block a user