forked from cpacia/bchutil
-
Notifications
You must be signed in to change notification settings - Fork 2
/
bitpayaddr_test.go
46 lines (38 loc) · 1.11 KB
/
bitpayaddr_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package bchutil
import (
"bytes"
"github.com/jakm/btcutil"
"github.com/jakm/btcutil/chaincfg"
"testing"
)
func TestDecodeBitpay(t *testing.T) {
chaincfg.RegisterBitcoinParams()
addr, err := DecodeBitpay("CLtewbVQHRvs2J9JzRo58aVCZAVF8VbkXU", &chaincfg.MainNetParams)
if err != nil {
t.Error(err)
}
if addr.String() != "CLtewbVQHRvs2J9JzRo58aVCZAVF8VbkXU" {
t.Error("Decoding failed")
}
addr2, err := btcutil.DecodeAddress("15RmNZ9LQNxL8AEtJgU9Z4sAw3GqJK99vf", &chaincfg.MainNetParams)
if err != nil {
t.Error(err)
}
if !bytes.Equal(addr.ScriptAddress(), addr2.ScriptAddress()) {
t.Error("Script doesn't match original btc address")
}
addr, err = DecodeBitpay("HDLrcK5m6yUx3ogjGyjwnevdbfYg26RVUa", &chaincfg.MainNetParams)
if err != nil {
t.Error(err)
}
if addr.String() != "HDLrcK5m6yUx3ogjGyjwnevdbfYg26RVUa" {
t.Error("Decoding failed")
}
addr2, err = btcutil.DecodeAddress("38Wk9WegFfGHRdohRJ5npGQ6a1Xf9guvs6", &chaincfg.MainNetParams)
if err != nil {
t.Error(err)
}
if !bytes.Equal(addr.ScriptAddress(), addr2.ScriptAddress()) {
t.Error("Script doesn't match original btc address")
}
}