@@ -284,12 +284,16 @@ struct PSBTInput
284
284
case PSBT_IN_NON_WITNESS_UTXO:
285
285
if (non_witness_utxo) {
286
286
throw std::ios_base::failure (" Duplicate Key, input non-witness utxo already provided" );
287
+ } else if (key.size () != 1 ) {
288
+ throw std::ios_base::failure (" Non-witness utxo key is more than one byte type" );
287
289
}
288
290
UnserializeFromVector (s, non_witness_utxo);
289
291
break ;
290
292
case PSBT_IN_WITNESS_UTXO:
291
293
if (!witness_utxo.IsNull ()) {
292
294
throw std::ios_base::failure (" Duplicate Key, input witness utxo already provided" );
295
+ } else if (key.size () != 1 ) {
296
+ throw std::ios_base::failure (" Witness utxo key is more than one byte type" );
293
297
}
294
298
UnserializeFromVector (s, witness_utxo);
295
299
break ;
@@ -319,13 +323,17 @@ struct PSBTInput
319
323
case PSBT_IN_SIGHASH:
320
324
if (sighash_type > 0 ) {
321
325
throw std::ios_base::failure (" Duplicate Key, input sighash type already provided" );
326
+ } else if (key.size () != 1 ) {
327
+ throw std::ios_base::failure (" Sighash type key is more than one byte type" );
322
328
}
323
329
UnserializeFromVector (s, sighash_type);
324
330
break ;
325
331
case PSBT_IN_REDEEMSCRIPT:
326
332
{
327
333
if (!redeem_script.empty ()) {
328
334
throw std::ios_base::failure (" Duplicate Key, input redeemScript already provided" );
335
+ } else if (key.size () != 1 ) {
336
+ throw std::ios_base::failure (" Input redeemScript key is more than one byte type" );
329
337
}
330
338
s >> redeem_script;
331
339
break ;
@@ -334,6 +342,8 @@ struct PSBTInput
334
342
{
335
343
if (!witness_script.empty ()) {
336
344
throw std::ios_base::failure (" Duplicate Key, input witnessScript already provided" );
345
+ } else if (key.size () != 1 ) {
346
+ throw std::ios_base::failure (" Input witnessScript key is more than one byte type" );
337
347
}
338
348
s >> witness_script;
339
349
break ;
@@ -347,6 +357,8 @@ struct PSBTInput
347
357
{
348
358
if (!final_script_sig.empty ()) {
349
359
throw std::ios_base::failure (" Duplicate Key, input final scriptSig already provided" );
360
+ } else if (key.size () != 1 ) {
361
+ throw std::ios_base::failure (" Final scriptSig key is more than one byte type" );
350
362
}
351
363
s >> final_script_sig;
352
364
break ;
@@ -355,6 +367,8 @@ struct PSBTInput
355
367
{
356
368
if (!final_script_witness.IsNull ()) {
357
369
throw std::ios_base::failure (" Duplicate Key, input final scriptWitness already provided" );
370
+ } else if (key.size () != 1 ) {
371
+ throw std::ios_base::failure (" Final scriptWitness key is more than one byte type" );
358
372
}
359
373
UnserializeFromVector (s, final_script_witness.stack );
360
374
break ;
@@ -442,6 +456,8 @@ struct PSBTOutput
442
456
{
443
457
if (!redeem_script.empty ()) {
444
458
throw std::ios_base::failure (" Duplicate Key, output redeemScript already provided" );
459
+ } else if (key.size () != 1 ) {
460
+ throw std::ios_base::failure (" Output redeemScript key is more than one byte type" );
445
461
}
446
462
s >> redeem_script;
447
463
break ;
@@ -450,6 +466,8 @@ struct PSBTOutput
450
466
{
451
467
if (!witness_script.empty ()) {
452
468
throw std::ios_base::failure (" Duplicate Key, output witnessScript already provided" );
469
+ } else if (key.size () != 1 ) {
470
+ throw std::ios_base::failure (" Output witnessScript key is more than one byte type" );
453
471
}
454
472
s >> witness_script;
455
473
break ;
@@ -564,6 +582,8 @@ struct PartiallySignedTransaction
564
582
{
565
583
if (tx) {
566
584
throw std::ios_base::failure (" Duplicate Key, unsigned tx already provided" );
585
+ } else if (key.size () != 1 ) {
586
+ throw std::ios_base::failure (" Global unsigned tx key is more than one byte type" );
567
587
}
568
588
CMutableTransaction mtx;
569
589
UnserializeFromVector (s, mtx);
0 commit comments