Serde implementation for PSBT
This commit is contained in:
parent
a4a7035a94
commit
00c3466363
|
@ -32,6 +32,7 @@ pub struct Global {
|
|||
/// Unknown global key-value pairs.
|
||||
pub unknown: BTreeMap<raw::Key, Vec<u8>>,
|
||||
}
|
||||
serde_struct_impl!(Global, unsigned_tx, unknown);
|
||||
|
||||
impl Global {
|
||||
/// Create a Global from an unsigned transaction, error if not unsigned
|
||||
|
|
|
@ -58,6 +58,11 @@ pub struct Input {
|
|||
/// Unknown key-value pairs for this input.
|
||||
pub unknown: BTreeMap<raw::Key, Vec<u8>>,
|
||||
}
|
||||
serde_struct_impl!(
|
||||
Input, non_witness_utxo, witness_utxo, partial_sigs,
|
||||
sighash_type, redeem_script, witness_script, hd_keypaths,
|
||||
final_script_sig, final_script_witness, unknown
|
||||
);
|
||||
|
||||
impl Map for Input {
|
||||
fn insert_pair(&mut self, pair: raw::Pair) -> Result<(), encode::Error> {
|
||||
|
|
|
@ -38,6 +38,9 @@ pub struct Output {
|
|||
/// Unknown key-value pairs for this output.
|
||||
pub unknown: BTreeMap<raw::Key, Vec<u8>>,
|
||||
}
|
||||
serde_struct_impl!(
|
||||
Output, redeem_script, witness_script, hd_keypaths, unknown
|
||||
);
|
||||
|
||||
impl Map for Output {
|
||||
fn insert_pair(&mut self, pair: raw::Pair) -> Result<(), encode::Error> {
|
||||
|
|
|
@ -49,6 +49,7 @@ pub struct PartiallySignedTransaction {
|
|||
/// transaction.
|
||||
pub outputs: Vec<Output>,
|
||||
}
|
||||
serde_struct_impl!(PartiallySignedTransaction, global, inputs, outputs);
|
||||
|
||||
impl PartiallySignedTransaction {
|
||||
/// Create a PartiallySignedTransaction from an unsigned transaction, error
|
||||
|
|
|
@ -31,6 +31,7 @@ pub struct Key {
|
|||
/// The key itself in raw byte form.
|
||||
pub key: Vec<u8>,
|
||||
}
|
||||
serde_struct_impl!(Key, type_value, key);
|
||||
|
||||
/// A PSBT key-value pair in its raw byte form.
|
||||
#[derive(Debug, PartialEq)]
|
||||
|
@ -40,6 +41,7 @@ pub struct Pair {
|
|||
/// The value of this key-value pair in raw byte form.
|
||||
pub value: Vec<u8>,
|
||||
}
|
||||
serde_struct_impl!(Pair, key, value);
|
||||
|
||||
impl fmt::Display for Key {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
|
|
Loading…
Reference in New Issue