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