@@ -300,14 +300,18 @@ struct PSBTInput
300
300
template <typename Stream>
301
301
inline void Unserialize (Stream& s) {
302
302
// Read loop
303
+ bool found_sep = false ;
303
304
while (!s.empty ()) {
304
305
// Read
305
306
std::vector<unsigned char > key;
306
307
s >> key;
307
308
308
309
// the key is empty if that was actually a separator byte
309
310
// This is a special case for key lengths 0 as those are not allowed (except for separator)
310
- if (key.empty ()) return ;
311
+ if (key.empty ()) {
312
+ found_sep = true ;
313
+ break ;
314
+ }
311
315
312
316
// First byte of key is the type
313
317
unsigned char type = key[0 ];
@@ -422,6 +426,10 @@ struct PSBTInput
422
426
break ;
423
427
}
424
428
}
429
+
430
+ if (!found_sep) {
431
+ throw std::ios_base::failure (" Separator is missing at the end of an input map" );
432
+ }
425
433
}
426
434
427
435
template <typename Stream>
@@ -475,14 +483,18 @@ struct PSBTOutput
475
483
template <typename Stream>
476
484
inline void Unserialize (Stream& s) {
477
485
// Read loop
486
+ bool found_sep = false ;
478
487
while (!s.empty ()) {
479
488
// Read
480
489
std::vector<unsigned char > key;
481
490
s >> key;
482
491
483
492
// the key is empty if that was actually a separator byte
484
493
// This is a special case for key lengths 0 as those are not allowed (except for separator)
485
- if (key.empty ()) return ;
494
+ if (key.empty ()) {
495
+ found_sep = true ;
496
+ break ;
497
+ }
486
498
487
499
// First byte of key is the type
488
500
unsigned char type = key[0 ];
@@ -527,6 +539,10 @@ struct PSBTOutput
527
539
}
528
540
}
529
541
}
542
+
543
+ if (!found_sep) {
544
+ throw std::ios_base::failure (" Separator is missing at the end of an output map" );
545
+ }
530
546
}
531
547
532
548
template <typename Stream>
@@ -602,14 +618,18 @@ struct PartiallySignedTransaction
602
618
}
603
619
604
620
// Read global data
621
+ bool found_sep = false ;
605
622
while (!s.empty ()) {
606
623
// Read
607
624
std::vector<unsigned char > key;
608
625
s >> key;
609
626
610
627
// the key is empty if that was actually a separator byte
611
628
// This is a special case for key lengths 0 as those are not allowed (except for separator)
612
- if (key.empty ()) break ;
629
+ if (key.empty ()) {
630
+ found_sep = true ;
631
+ break ;
632
+ }
613
633
614
634
// First byte of key is the type
615
635
unsigned char type = key[0 ];
@@ -649,6 +669,10 @@ struct PartiallySignedTransaction
649
669
}
650
670
}
651
671
672
+ if (!found_sep) {
673
+ throw std::ios_base::failure (" Separator is missing at the end of the global map" );
674
+ }
675
+
652
676
// Make sure that we got an unsigned tx
653
677
if (!tx) {
654
678
throw std::ios_base::failure (" No unsigned transcation was provided" );
0 commit comments