File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -401,7 +401,7 @@ impl Payload {
401
401
Payload :: ScriptHash ( ScriptHash :: from_inner ( hash_inner) )
402
402
} else if script. is_witness_program ( ) {
403
403
if script. witness_version ( ) == Some ( WitnessVersion :: V0 ) && !( script. is_v0_p2wpkh ( ) || script. is_v0_p2wsh ( ) ) {
404
- return Err ( Error :: InvalidSegwitV0ProgramLength ( script. len ( ) ) ) ;
404
+ return Err ( Error :: InvalidSegwitV0ProgramLength ( script. len ( ) - 2 ) ) ;
405
405
}
406
406
407
407
Payload :: WitnessProgram {
@@ -1430,9 +1430,11 @@ mod tests {
1430
1430
fn test_fail_address_from_script ( ) {
1431
1431
let bad_p2wpkh = hex_script ! ( "0014dbc5b0a8f9d4353b4b54c3db48846bb15abfec" ) ;
1432
1432
let bad_p2wsh = hex_script ! ( "00202d4fa2eb233d008cc83206fa2f4f2e60199000f5b857a835e3172323385623" ) ;
1433
+ let invalid_segwitv0_script = hex_script ! ( "001161458e330389cd0437ee9fe3641d70cc18" ) ;
1433
1434
let expected = Err ( Error :: UnrecognizedScript ) ;
1434
1435
1435
1436
assert_eq ! ( Address :: from_script( & bad_p2wpkh, Network :: Bitcoin ) , expected) ;
1436
1437
assert_eq ! ( Address :: from_script( & bad_p2wsh, Network :: Bitcoin ) , expected) ;
1438
+ assert_eq ! ( Address :: from_script( & invalid_segwitv0_script, Network :: Bitcoin ) , Err ( Error :: InvalidSegwitV0ProgramLength ( 17 ) ) ) ;
1437
1439
}
1438
1440
}
You can’t perform that action at this time.
0 commit comments