@@ -48,19 +48,20 @@ fn main() {
48
48
// transaction's inputs and outputs.
49
49
let s = format ! (
50
50
"tr({},{{pkh({}),{{multi_a(1,{},{}),and_v(v:pk({}),after(10))}}}})" ,
51
- keys[ 0 ] , keys[ 1 ] , keys[ 2 ] , keys[ 3 ] , keys[ 4 ]
51
+ keys[ 0 ] , // Key A
52
+ keys[ 1 ] , // Key B
53
+ keys[ 2 ] , // Key C
54
+ keys[ 3 ] , // Key D
55
+ keys[ 4 ] , // Key E
52
56
) ;
53
57
54
- let bridge_descriptor = Descriptor :: from_str ( & s) . expect ( "parse descriptor string" ) ;
55
- assert ! ( bridge_descriptor . sanity_check( ) . is_ok( ) ) ;
58
+ let descriptor = Descriptor :: from_str ( & s) . expect ( "parse descriptor string" ) ;
59
+ assert ! ( descriptor . sanity_check( ) . is_ok( ) ) ;
56
60
61
+ println ! ( "Descriptor pubkey script: {}" , descriptor. script_pubkey( ) ) ;
57
62
println ! (
58
- "Bridge pubkey script: {}" ,
59
- bridge_descriptor. script_pubkey( )
60
- ) ;
61
- println ! (
62
- "Bridge address: {}" ,
63
- bridge_descriptor. address( Network :: Regtest ) . unwrap( )
63
+ "Descriptor address: {}" ,
64
+ descriptor. address( Network :: Regtest ) . unwrap( )
64
65
) ;
65
66
66
67
let master_private_key_str = "KxQqtbUnMugSEbKHG3saknvVYux1cgFjFqWzMfwnFhLm8QrGq26v" ;
@@ -113,7 +114,7 @@ fn main() {
113
114
114
115
let amount = 100000000 ;
115
116
116
- let ( outpoint, witness_utxo) = get_vout ( & depo_tx, bridge_descriptor . script_pubkey ( ) ) ;
117
+ let ( outpoint, witness_utxo) = get_vout ( & depo_tx, descriptor . script_pubkey ( ) ) ;
117
118
118
119
let all_assets = Descriptor :: < DescriptorPublicKey > :: from_str ( & s)
119
120
. unwrap ( )
@@ -145,7 +146,7 @@ fn main() {
145
146
} ) ;
146
147
147
148
psbt. unsigned_tx . output . push ( TxOut {
148
- script_pubkey : bridge_descriptor . script_pubkey ( ) ,
149
+ script_pubkey : descriptor . script_pubkey ( ) ,
149
150
value : amount * 4 / 5 ,
150
151
} ) ;
151
152
@@ -157,16 +158,14 @@ fn main() {
157
158
// We have to add the keys to `Asset` and then obtain plan with only available signatures if the descriptor can be satisfied.
158
159
159
160
// Obtain the Plan based on available Assets
160
- let plan = bridge_descriptor . clone ( ) . plan ( & asset) . unwrap ( ) ;
161
+ let plan = descriptor . clone ( ) . plan ( & asset) . unwrap ( ) ;
161
162
162
163
// Creating PSBT Input
163
164
let mut input = psbt:: Input :: default ( ) ;
164
165
plan. update_psbt_input ( & mut input) ;
165
166
166
167
// Update the PSBT input from the result which we have obtained from the Plan.
167
- input
168
- . update_with_descriptor_unchecked ( & bridge_descriptor)
169
- . unwrap ( ) ;
168
+ input. update_with_descriptor_unchecked ( & descriptor) . unwrap ( ) ;
170
169
input. witness_utxo = Some ( witness_utxo. clone ( ) ) ;
171
170
172
171
// Push the PSBT Input and declare an PSBT Output Structure
0 commit comments