Skip to content

Commit

Permalink
Testnet support (#179)
Browse files Browse the repository at this point in the history
* added factory method FromPublicKeys for creating multiscript payment

* testnet support
  • Loading branch information
sekulicd authored Oct 22, 2021
1 parent 71dd075 commit 96f39d0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 11 additions & 0 deletions address/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,11 @@ func NetworkForAddress(address string) (*network.Network, error) {
return &network.Regtest, nil
}

if strings.HasPrefix(address, network.Testnet.Bech32) ||
strings.HasPrefix(address, network.Testnet.Blech32) {
return &network.Testnet, nil
}

_, prefix, err := base58.CheckDecode(address)
if err != nil {
return nil, err
Expand All @@ -409,6 +414,12 @@ func NetworkForAddress(address string) (*network.Network, error) {
return &network.Regtest, nil
}

if prefix == network.Testnet.Confidential ||
prefix == network.Testnet.PubKeyHash ||
prefix == network.Testnet.ScriptHash {
return &network.Testnet, nil
}

return nil, errors.New("unknown prefix for address")
}

Expand Down
16 changes: 15 additions & 1 deletion network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var Liquid = Network{
AssetID: "6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d",
}

// Regtest defines the network parameters for the regression test network.
// Regtest defines the network parameters for the regression regtest network.
var Regtest = Network{
Name: "regtest",
Bech32: "ert",
Expand All @@ -51,3 +51,17 @@ var Regtest = Network{
Confidential: 4,
AssetID: "5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225",
}

// Testnet defines the network parameters for the regression testnet network.
var Testnet = Network{
Name: "testnet",
Bech32: "tex",
Blech32: "tlq",
HDPublicKey: [4]byte{0x04, 0x35, 0x87, 0xcf},
HDPrivateKey: [4]byte{0x04, 0x35, 0x83, 0x94},
PubKeyHash: 36,
ScriptHash: 19,
Wif: 0xef,
Confidential: 23,
AssetID: "144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49",
}

0 comments on commit 96f39d0

Please sign in to comment.