Skip to content

Commit db805b3

Browse files
committed
pset: output: add asset blinding factor
1 parent d1dfed4 commit db805b3

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/pset/map/output.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::encode::Decodable;
2222
use crate::pset::map::Map;
2323
use crate::pset::raw;
2424
use crate::pset::Error;
25-
use crate::{confidential, pset};
25+
use crate::{confidential::{self, AssetBlindingFactor}, pset};
2626
use crate::{encode, Script, TxOutWitness};
2727
use bitcoin::bip32::KeySource;
2828
use bitcoin::{PublicKey, key::XOnlyPublicKey};
@@ -83,6 +83,8 @@ const PSBT_ELEMENTS_OUT_BLIND_VALUE_PROOF: u8 = 0x09;
8383
/// PSBT_ELEMENTS_OUT_ASSET. If provided, PSBT_ELEMENTS_OUT_ASSET_COMMITMENT must
8484
/// be provided too.
8585
const PSBT_ELEMENTS_OUT_BLIND_ASSET_PROOF: u8 = 0x0a;
86+
/// The 32 byte asset blinding factor for this output.
87+
const PSBT_ELEMENTS_OUT_ASSET_BLINDING_FACTOR: u8 = 0x0b;
8688

8789
/// A key-value map for an output of the corresponding index in the unsigned
8890
/// transaction.
@@ -129,6 +131,8 @@ pub struct Output {
129131
pub blind_value_proof: Option<Box<RangeProof>>,
130132
/// The blind asset surjection proof
131133
pub blind_asset_proof: Option<Box<SurjectionProof>>,
134+
/// The 32 byte asset blinding factor
135+
pub asset_blinding_factor: Option<AssetBlindingFactor>,
132136
/// Pset
133137
/// Other fields
134138
#[cfg_attr(
@@ -374,6 +378,9 @@ impl Map for Output {
374378
PSBT_ELEMENTS_OUT_BLIND_ASSET_PROOF => {
375379
impl_pset_prop_insert_pair!(self.blind_asset_proof <= <raw_key: _> | <raw_value : Box<SurjectionProof>>)
376380
}
381+
PSBT_ELEMENTS_OUT_ASSET_BLINDING_FACTOR => {
382+
impl_pset_prop_insert_pair!(self.asset_blinding_factor <= <raw_key: _> | <raw_value : AssetBlindingFactor>)
383+
}
377384
_ => match self.proprietary.entry(prop_key) {
378385
Entry::Vacant(empty_key) => {
379386
empty_key.insert(raw_value);
@@ -488,6 +495,10 @@ impl Map for Output {
488495
rv.push_prop(self.blind_asset_proof as <PSBT_ELEMENTS_OUT_BLIND_ASSET_PROOF, _>)
489496
}
490497

498+
impl_pset_get_pair! {
499+
rv.push_prop(self.asset_blinding_factor as <PSBT_ELEMENTS_OUT_ASSET_BLINDING_FACTOR, _>)
500+
}
501+
491502
for (key, value) in self.proprietary.iter() {
492503
rv.push(raw::Pair {
493504
key: key.to_key(),
@@ -525,6 +536,7 @@ impl Map for Output {
525536
merge!(blinder_index, self, other);
526537
merge!(blind_value_proof, self, other);
527538
merge!(blind_asset_proof, self, other);
539+
merge!(asset_blinding_factor, self, other);
528540
Ok(())
529541
}
530542
}

0 commit comments

Comments
 (0)