From 3df85bdcfcb38cf72848f07236c888bf0b8f4402 Mon Sep 17 00:00:00 2001 From: josh Date: Sun, 8 Apr 2018 19:38:12 -0700 Subject: [PATCH] p2sh validation and more tests --- baked_in.go | 2 +- validator_test.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/baked_in.go b/baked_in.go index 55bd4c4..41f68a2 100644 --- a/baked_in.go +++ b/baked_in.go @@ -423,7 +423,7 @@ func isBitcoinAddress(fl FieldLevel) bool { } - if decode[0] != 0 { + if !(decode[0] == 0 || decode[0] == 5) { return false } diff --git a/validator_test.go b/validator_test.go index c16d426..aaab196 100644 --- a/validator_test.go +++ b/validator_test.go @@ -4446,7 +4446,10 @@ func TestBitcoinAddressValidation(t *testing.T){ }{ {"", false}, {"0x02F9AE5f22EA3fA88F05780B30385bEC", false}, - {"1A1zP1ePQGefi2DMPTifTL5SLmv7DivfNa", false}, + {"1A1zP1ePQGefi2DMPTifTL5SLmv7DivfNa", false}, // invalid p2pkh address with invalid characters + {"1P9RQEr2XeE3PEb44ZE35sfZRRW1JH8Uqx", false}, // invald p2pkh address with valid characters + {"3P14159I73E4gFr7JterCCQh9QjiTjiZrG", false}, // invalid p2sh address with invalid characters + {"3P141597f3E4gFr7JterCCQh9QjiTjiZrG", false}, // invalid p2sh address with valid characters {"1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2", true}, // valid p2pkh address {"3P14159f73E4gFr7JterCCQh9QjiTjiZrG", true}, // valid p2sh address {"bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq", true}, // valid bech32 address