diff --git a/ledger/common.go b/ledger/common.go index b8dec7af..46f83cf0 100644 --- a/ledger/common.go +++ b/ledger/common.go @@ -189,6 +189,9 @@ const ( AddressHeaderNetworkMask = 0x0F AddressHashSize = 28 + AddressNetworkTestnet = 0 + AddressNetworkMainnet = 1 + AddressTypeKeyKey = 0b0000 AddressTypeScriptKey = 0b0001 AddressTypeKeyScript = 0b0010 @@ -323,7 +326,7 @@ func (a Address) generateHRP() string { ret = "addr" } // Add test_ suffix if not mainnet - if a.networkId != 1 { + if a.networkId != AddressNetworkMainnet { ret += "_test" } return ret diff --git a/networks.go b/networks.go index 442da7c8..e1496bb0 100644 --- a/networks.go +++ b/networks.go @@ -14,32 +14,40 @@ package ouroboros +import ( + "github.com/blinklabs-io/gouroboros/ledger" +) + // Network definitions var ( - NetworkTestnet = Network{Id: 0, Name: "testnet", NetworkMagic: 1097911063} + NetworkTestnet = Network{ + Id: ledger.AddressNetworkTestnet, + Name: "testnet", + NetworkMagic: 1097911063, + } NetworkMainnet = Network{ - Id: 1, + Id: ledger.AddressNetworkMainnet, Name: "mainnet", NetworkMagic: 764824073, PublicRootAddress: "backbone.cardano-mainnet.iohk.io", PublicRootPort: 3001, } NetworkPreprod = Network{ - Id: 2, + Id: ledger.AddressNetworkTestnet, Name: "preprod", NetworkMagic: 1, PublicRootAddress: "preprod-node.world.dev.cardano.org", PublicRootPort: 30000, } NetworkPreview = Network{ - Id: 3, + Id: ledger.AddressNetworkTestnet, Name: "preview", NetworkMagic: 2, PublicRootAddress: "preview-node.play.dev.cardano.org", PublicRootPort: 3001, } NetworkSancho = Network{ - Id: 4, + Id: ledger.AddressNetworkTestnet, Name: "sanchonet", NetworkMagic: 4, PublicRootAddress: "sanchonet-node.play.dev.cardano.org", @@ -94,7 +102,7 @@ func NetworkByNetworkMagic(networkMagic uint32) Network { // Network represents a Cardano network type Network struct { - Id uint8 + Id uint8 // network ID used for addresses Name string NetworkMagic uint32 PublicRootAddress string