Skip to content

Commit 96f39d0

Browse files
authored
Testnet support (#179)
* added factory method FromPublicKeys for creating multiscript payment * testnet support
1 parent 71dd075 commit 96f39d0

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

address/address.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,11 @@ func NetworkForAddress(address string) (*network.Network, error) {
392392
return &network.Regtest, nil
393393
}
394394

395+
if strings.HasPrefix(address, network.Testnet.Bech32) ||
396+
strings.HasPrefix(address, network.Testnet.Blech32) {
397+
return &network.Testnet, nil
398+
}
399+
395400
_, prefix, err := base58.CheckDecode(address)
396401
if err != nil {
397402
return nil, err
@@ -409,6 +414,12 @@ func NetworkForAddress(address string) (*network.Network, error) {
409414
return &network.Regtest, nil
410415
}
411416

417+
if prefix == network.Testnet.Confidential ||
418+
prefix == network.Testnet.PubKeyHash ||
419+
prefix == network.Testnet.ScriptHash {
420+
return &network.Testnet, nil
421+
}
422+
412423
return nil, errors.New("unknown prefix for address")
413424
}
414425

network/network.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var Liquid = Network{
3838
AssetID: "6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d",
3939
}
4040

41-
// Regtest defines the network parameters for the regression test network.
41+
// Regtest defines the network parameters for the regression regtest network.
4242
var Regtest = Network{
4343
Name: "regtest",
4444
Bech32: "ert",
@@ -51,3 +51,17 @@ var Regtest = Network{
5151
Confidential: 4,
5252
AssetID: "5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225",
5353
}
54+
55+
// Testnet defines the network parameters for the regression testnet network.
56+
var Testnet = Network{
57+
Name: "testnet",
58+
Bech32: "tex",
59+
Blech32: "tlq",
60+
HDPublicKey: [4]byte{0x04, 0x35, 0x87, 0xcf},
61+
HDPrivateKey: [4]byte{0x04, 0x35, 0x83, 0x94},
62+
PubKeyHash: 36,
63+
ScriptHash: 19,
64+
Wif: 0xef,
65+
Confidential: 23,
66+
AssetID: "144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49",
67+
}

0 commit comments

Comments
 (0)