@@ -367,7 +367,7 @@ impl TxOut {
367367 /// Whether this output is a pegout, which is a subset of nulldata with the
368368 /// following extra rules: (a) there must be at least 2 pushes, the first of
369369 /// which must be 32 bytes; (b) all pushes must use a push opcode rather than
370- /// a numeric or reserved opcode.
370+ /// a numeric or reserved opcode; (c) empty pushes are not allowed
371371 pub fn is_pegout ( & self ) -> bool {
372372 self . pegout_data ( ) . is_some ( )
373373 }
@@ -413,7 +413,12 @@ impl TxOut {
413413 let mut found_non_data_push = false ;
414414 let remainder = iter
415415 . filter_map ( |x| if let Instruction :: PushBytes ( data) = x {
416- Some ( data)
416+ if data. is_empty ( ) {
417+ found_non_data_push = true ;
418+ None
419+ } else {
420+ Some ( data)
421+ }
417422 } else {
418423 found_non_data_push = true ;
419424 None
@@ -1595,5 +1600,46 @@ mod tests {
15951600 assert_eq ! ( tx. output[ 0 ] . asset, tx. output[ 1 ] . asset) ;
15961601 assert_eq ! ( tx. output[ 2 ] . asset, tx. output[ 1 ] . asset) ;
15971602 }
1603+
1604+ #[ test]
1605+ fn pegout_with_null_pak ( ) {
1606+ let tx: Transaction = hex_deserialize ! ( "\
1607+ 0200000000021c39a226160dd8962eb273772950f0b603c319a8e4aa9912c9e8\
1608+ e36b5bdf71a2000000006a473044022071212fcde89d1055d5b74f17a162b3db\
1609+ e5348ac8527a131dab5dcf8a97d67d2f02202edf12f3c69fed1fa0c23da608e6\
1610+ aded86dd5c7b09da42f61b453c3a838e8cab012103557f25ff40f976670ddf59\
1611+ c71938bade91684b76ad69dfed27049de2afec59e5feffffff853db31f986dd8\
1612+ 9c81fe87a84f385d7099c5ea841d762b26b03166e5e798dfbe000000006a4730\
1613+ 44022042c70729fb50930179a9d76f5febbda5b0ee50e62febf92de4dd10b939\
1614+ 3554d802203140b107519243e4110c065017c8ae1ac04843f94b3f20a1e5faf7\
1615+ 343dd76159012102797ffcf7ccc8e2012a90e71962901a1ad740f2a28f2f563c\
1616+ 76f9eb42a8100f5efeffffff03016d521c38ec1ea15734ae22b7c46064412829\
1617+ c0d0579f0a713d1c04ede979026f0100000000000f7869001976a914216d878e\
1618+ bff0c623909889265d8dc1ab26e2ff4388ac016d521c38ec1ea15734ae22b7c4\
1619+ 6064412829c0d0579f0a713d1c04ede979026f0100000000000186a0005f6a20\
1620+ 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000\
1621+ 1976a914df662e2dd70fd82acba2d252cc897cb6e618093288ac21025f756509\
1622+ f5dbac47d54c9ef5ccf49895a4dbac4759005a74375f66c480e6c08600016d52\
1623+ 1c38ec1ea15734ae22b7c46064412829c0d0579f0a713d1c04ede979026f0100\
1624+ 000000000006fc000054840300\
1625+ ") ;
1626+
1627+ assert_eq ! ( tx. input. len( ) , 2 ) ;
1628+ assert_eq ! ( tx. output. len( ) , 3 ) ;
1629+ assert ! ( !tx. output[ 0 ] . is_null_data( ) ) ;
1630+ assert ! ( !tx. output[ 0 ] . is_pegout( ) ) ;
1631+ assert ! ( !tx. output[ 0 ] . is_fee( ) ) ;
1632+
1633+ assert ! ( tx. output[ 1 ] . is_null_data( ) ) ;
1634+ assert ! ( !tx. output[ 1 ] . is_pegout( ) ) ;
1635+ assert ! ( !tx. output[ 1 ] . is_fee( ) ) ;
1636+
1637+ assert ! ( !tx. output[ 2 ] . is_null_data( ) ) ;
1638+ assert ! ( !tx. output[ 2 ] . is_pegout( ) ) ;
1639+ assert ! ( tx. output[ 2 ] . is_fee( ) ) ;
1640+
1641+ assert_eq ! ( tx. output[ 0 ] . asset, tx. output[ 1 ] . asset) ;
1642+ assert_eq ! ( tx. output[ 2 ] . asset, tx. output[ 1 ] . asset) ;
1643+ }
15981644}
15991645
0 commit comments