@@ -213,40 +213,40 @@ def serialize(self) -> bytes:
213
213
r = b""
214
214
215
215
if self .non_witness_utxo :
216
- r += ser_string (b" \x00 " )
216
+ r += ser_string (ser_compact_size ( PartiallySignedInput . PSBT_IN_NON_WITNESS_UTXO ) )
217
217
tx = self .non_witness_utxo .serialize_with_witness ()
218
218
r += ser_string (tx )
219
219
220
220
if self .witness_utxo :
221
- r += ser_string (b" \x01 " )
221
+ r += ser_string (ser_compact_size ( PartiallySignedInput . PSBT_IN_WITNESS_UTXO ) )
222
222
tx = self .witness_utxo .serialize ()
223
223
r += ser_string (tx )
224
224
225
225
if len (self .final_script_sig ) == 0 and self .final_script_witness .is_null ():
226
226
for pubkey , sig in sorted (self .partial_sigs .items ()):
227
- r += ser_string (b" \x02 " + pubkey )
227
+ r += ser_string (ser_compact_size ( PartiallySignedInput . PSBT_IN_PARTIAL_SIG ) + pubkey )
228
228
r += ser_string (sig )
229
229
230
230
if self .sighash is not None :
231
- r += ser_string (b" \x03 " )
231
+ r += ser_string (ser_compact_size ( PartiallySignedInput . PSBT_IN_SIGHASH_TYPE ) )
232
232
r += ser_string (struct .pack ("<I" , self .sighash ))
233
233
234
234
if len (self .redeem_script ) != 0 :
235
- r += ser_string (b" \x04 " )
235
+ r += ser_string (ser_compact_size ( PartiallySignedInput . PSBT_IN_REDEEM_SCRIPT ) )
236
236
r += ser_string (self .redeem_script )
237
237
238
238
if len (self .witness_script ) != 0 :
239
- r += ser_string (b" \x05 " )
239
+ r += ser_string (ser_compact_size ( PartiallySignedInput . PSBT_IN_WITNESS_SCRIPT ) )
240
240
r += ser_string (self .witness_script )
241
241
242
- r += SerializeHDKeypath (self .hd_keypaths , b" \x06 " )
242
+ r += SerializeHDKeypath (self .hd_keypaths , ser_compact_size ( PartiallySignedInput . PSBT_IN_BIP32_DERIVATION ) )
243
243
244
244
if len (self .final_script_sig ) != 0 :
245
- r += ser_string (b" \x07 " )
245
+ r += ser_string (ser_compact_size ( PartiallySignedInput . PSBT_IN_FINAL_SCRIPTSIG ) )
246
246
r += ser_string (self .final_script_sig )
247
247
248
248
if not self .final_script_witness .is_null ():
249
- r += ser_string (b" \x08 " )
249
+ r += ser_string (ser_compact_size ( PartiallySignedInput . PSBT_IN_FINAL_SCRIPTWITNESS ) )
250
250
witstack = self .final_script_witness .serialize ()
251
251
r += ser_string (witstack )
252
252
@@ -334,14 +334,14 @@ def serialize(self) -> bytes:
334
334
"""
335
335
r = b""
336
336
if len (self .redeem_script ) != 0 :
337
- r += ser_string (b" \x00 " )
337
+ r += ser_string (ser_compact_size ( PartiallySignedOutput . PSBT_OUT_REDEEM_SCRIPT ) )
338
338
r += ser_string (self .redeem_script )
339
339
340
340
if len (self .witness_script ) != 0 :
341
- r += ser_string (b" \x01 " )
341
+ r += ser_string (ser_compact_size ( PartiallySignedOutput . PSBT_OUT_WITNESS_SCRIPT ) )
342
342
r += ser_string (self .witness_script )
343
343
344
- r += SerializeHDKeypath (self .hd_keypaths , b" \x02 " )
344
+ r += SerializeHDKeypath (self .hd_keypaths , ser_compact_size ( PartiallySignedOutput . PSBT_OUT_BIP32_DERIVATION ) )
345
345
346
346
for key , value in sorted (self .unknown .items ()):
347
347
r += ser_string (key )
@@ -473,15 +473,15 @@ def serialize(self) -> str:
473
473
r += b"psbt\xff "
474
474
475
475
# unsigned tx flag
476
- r += b" \x01 \x00 "
476
+ r += ser_string ( ser_compact_size ( PSBT . PSBT_GLOBAL_UNSIGNED_TX ))
477
477
478
478
# write serialized tx
479
479
tx = self .tx .serialize_with_witness ()
480
480
r += ser_compact_size (len (tx ))
481
481
r += tx
482
482
483
483
# write xpubs
484
- r += SerializeHDKeypath (self .xpub , b" \x01 " )
484
+ r += SerializeHDKeypath (self .xpub , ser_compact_size ( PSBT . PSBT_GLOBAL_XPUB ) )
485
485
486
486
# unknowns
487
487
for key , value in sorted (self .unknown .items ()):
0 commit comments