@@ -23,7 +23,7 @@ use std::{
2323use crate :: taproot:: { ControlBlock , LeafVersion , TapNodeHash , TapLeafHash } ;
2424use crate :: { schnorr, AssetId , ContractHash } ;
2525
26- use crate :: { confidential, locktime} ;
26+ use crate :: { confidential:: { self , AssetBlindingFactor } , locktime} ;
2727use crate :: encode:: { self , Decodable } ;
2828use crate :: hashes:: { self , hash160, ripemd160, sha256, sha256d, Hash } ;
2929use crate :: pset:: map:: Map ;
@@ -168,6 +168,8 @@ const PSBT_ELEMENTS_IN_ASSET_PROOF: u8 = 0x14;
168168/// Note that this does not indicate actual blinding status,
169169/// but rather the expected blinding status prior to signing.
170170const PSBT_ELEMENTS_IN_BLINDED_ISSUANCE : u8 = 0x15 ;
171+ /// The 32 byte asset blinding factor for the input being spent.
172+ const PSBT_ELEMENTS_IN_ASSET_BLINDING_FACTOR : u8 = 0x16 ;
171173/// A key-value map for an input of the corresponding index in the unsigned
172174/// transaction.
173175#[ derive( Clone , Debug , PartialEq ) ]
@@ -301,6 +303,8 @@ pub struct Input {
301303 pub blind_asset_proof : Option < Box < SurjectionProof > > ,
302304 /// Whether the issuance is blinded
303305 pub blinded_issuance : Option < u8 > ,
306+ /// The input asset blinding factor
307+ pub asset_blinding_factor : Option < AssetBlindingFactor > ,
304308 /// Other fields
305309 #[ cfg_attr(
306310 feature = "serde" ,
@@ -317,7 +321,7 @@ pub struct Input {
317321
318322impl Default for Input {
319323 fn default ( ) -> Self {
320- Self { non_witness_utxo : Default :: default ( ) , witness_utxo : Default :: default ( ) , partial_sigs : Default :: default ( ) , sighash_type : Default :: default ( ) , redeem_script : Default :: default ( ) , witness_script : Default :: default ( ) , bip32_derivation : Default :: default ( ) , final_script_sig : Default :: default ( ) , final_script_witness : Default :: default ( ) , ripemd160_preimages : Default :: default ( ) , sha256_preimages : Default :: default ( ) , hash160_preimages : Default :: default ( ) , hash256_preimages : Default :: default ( ) , previous_txid : Txid :: all_zeros ( ) , previous_output_index : Default :: default ( ) , sequence : Default :: default ( ) , required_time_locktime : Default :: default ( ) , required_height_locktime : Default :: default ( ) , tap_key_sig : Default :: default ( ) , tap_script_sigs : Default :: default ( ) , tap_scripts : Default :: default ( ) , tap_key_origins : Default :: default ( ) , tap_internal_key : Default :: default ( ) , tap_merkle_root : Default :: default ( ) , issuance_value_amount : Default :: default ( ) , issuance_value_comm : Default :: default ( ) , issuance_value_rangeproof : Default :: default ( ) , issuance_keys_rangeproof : Default :: default ( ) , pegin_tx : Default :: default ( ) , pegin_txout_proof : Default :: default ( ) , pegin_genesis_hash : Default :: default ( ) , pegin_claim_script : Default :: default ( ) , pegin_value : Default :: default ( ) , pegin_witness : Default :: default ( ) , issuance_inflation_keys : Default :: default ( ) , issuance_inflation_keys_comm : Default :: default ( ) , issuance_blinding_nonce : Default :: default ( ) , issuance_asset_entropy : Default :: default ( ) , in_utxo_rangeproof : Default :: default ( ) , in_issuance_blind_value_proof : Default :: default ( ) , in_issuance_blind_inflation_keys_proof : Default :: default ( ) , amount : Default :: default ( ) , blind_value_proof : Default :: default ( ) , asset : Default :: default ( ) , blind_asset_proof : Default :: default ( ) , blinded_issuance : Default :: default ( ) , proprietary : Default :: default ( ) , unknown : Default :: default ( ) }
324+ Self { non_witness_utxo : Default :: default ( ) , witness_utxo : Default :: default ( ) , partial_sigs : Default :: default ( ) , sighash_type : Default :: default ( ) , redeem_script : Default :: default ( ) , witness_script : Default :: default ( ) , bip32_derivation : Default :: default ( ) , final_script_sig : Default :: default ( ) , final_script_witness : Default :: default ( ) , ripemd160_preimages : Default :: default ( ) , sha256_preimages : Default :: default ( ) , hash160_preimages : Default :: default ( ) , hash256_preimages : Default :: default ( ) , previous_txid : Txid :: all_zeros ( ) , previous_output_index : Default :: default ( ) , sequence : Default :: default ( ) , required_time_locktime : Default :: default ( ) , required_height_locktime : Default :: default ( ) , tap_key_sig : Default :: default ( ) , tap_script_sigs : Default :: default ( ) , tap_scripts : Default :: default ( ) , tap_key_origins : Default :: default ( ) , tap_internal_key : Default :: default ( ) , tap_merkle_root : Default :: default ( ) , issuance_value_amount : Default :: default ( ) , issuance_value_comm : Default :: default ( ) , issuance_value_rangeproof : Default :: default ( ) , issuance_keys_rangeproof : Default :: default ( ) , pegin_tx : Default :: default ( ) , pegin_txout_proof : Default :: default ( ) , pegin_genesis_hash : Default :: default ( ) , pegin_claim_script : Default :: default ( ) , pegin_value : Default :: default ( ) , pegin_witness : Default :: default ( ) , issuance_inflation_keys : Default :: default ( ) , issuance_inflation_keys_comm : Default :: default ( ) , issuance_blinding_nonce : Default :: default ( ) , issuance_asset_entropy : Default :: default ( ) , in_utxo_rangeproof : Default :: default ( ) , in_issuance_blind_value_proof : Default :: default ( ) , in_issuance_blind_inflation_keys_proof : Default :: default ( ) , amount : Default :: default ( ) , blind_value_proof : Default :: default ( ) , asset : Default :: default ( ) , blind_asset_proof : Default :: default ( ) , blinded_issuance : Default :: default ( ) , asset_blinding_factor : Default :: default ( ) , proprietary : Default :: default ( ) , unknown : Default :: default ( ) }
321325 }
322326}
323327
@@ -750,6 +754,9 @@ impl Map for Input {
750754 PSBT_ELEMENTS_IN_BLINDED_ISSUANCE => {
751755 impl_pset_prop_insert_pair ! ( self . blinded_issuance <= <raw_key: _> | <raw_value : u8 >)
752756 }
757+ PSBT_ELEMENTS_IN_ASSET_BLINDING_FACTOR => {
758+ impl_pset_prop_insert_pair ! ( self . asset_blinding_factor <= <raw_key: _> | <raw_value : AssetBlindingFactor >)
759+ }
753760 _ => match self . proprietary . entry ( prop_key) {
754761 Entry :: Vacant ( empty_key) => {
755762 empty_key. insert ( raw_value) ;
@@ -968,6 +975,10 @@ impl Map for Input {
968975 rv. push_prop( self . blinded_issuance as <PSBT_ELEMENTS_IN_BLINDED_ISSUANCE , _>)
969976 }
970977
978+ impl_pset_get_pair ! {
979+ rv. push_prop( self . asset_blinding_factor as <PSBT_ELEMENTS_IN_ASSET_BLINDING_FACTOR , _>)
980+ }
981+
971982 for ( key, value) in self . proprietary . iter ( ) {
972983 rv. push ( raw:: Pair {
973984 key : key. to_key ( ) ,
@@ -1047,6 +1058,7 @@ impl Map for Input {
10471058 merge ! ( asset, self , other) ;
10481059 merge ! ( blind_asset_proof, self , other) ;
10491060 merge ! ( blinded_issuance, self , other) ;
1061+ merge ! ( asset_blinding_factor, self , other) ;
10501062 Ok ( ( ) )
10511063 }
10521064}
0 commit comments