decred.org/dcrdex@v1.0.5/dex/networks/ltc/params.go (about)

     1  // This code is available on the terms of the project LICENSE.md file,
     2  // also available online at https://blueoakcouncil.org
     3  
     4  package ltc
     5  
     6  import (
     7  	"decred.org/dcrdex/dex"
     8  	"decred.org/dcrdex/dex/networks/btc"
     9  	"github.com/btcsuite/btcd/chaincfg"
    10  	"github.com/btcsuite/btcd/chaincfg/chainhash"
    11  )
    12  
    13  func mustHash(hash string) *chainhash.Hash {
    14  	h, err := chainhash.NewHashFromStr(hash)
    15  	if err != nil {
    16  		panic(err.Error())
    17  	}
    18  	return h
    19  }
    20  
    21  var (
    22  	UnitInfo = dex.UnitInfo{
    23  		AtomicUnit: "litoshi",
    24  		Conventional: dex.Denomination{
    25  			Unit:             "LTC",
    26  			ConversionFactor: 1e8,
    27  		},
    28  		Alternatives: []dex.Denomination{
    29  			{
    30  				Unit:             "mLTC",
    31  				ConversionFactor: 1e5,
    32  			},
    33  			{
    34  				Unit:             "µLTC",
    35  				ConversionFactor: 1e2,
    36  			},
    37  		},
    38  		FeeRateDenom: "vB",
    39  	}
    40  	// MainNetParams are the clone parameters for mainnet.
    41  	MainNetParams = btc.ReadCloneParams(&btc.CloneParams{
    42  		Name:             "mainnet",
    43  		PubKeyHashAddrID: 0x30, // starts with L
    44  		ScriptHashAddrID: 0x32, // starts with M
    45  		Bech32HRPSegwit:  "ltc",
    46  		CoinbaseMaturity: 100,
    47  		Net:              0xdbb6c0fb,
    48  		HDPrivateKeyID:   [4]byte{0x04, 0x88, 0xad, 0xe4}, // starts with xprv
    49  		HDPublicKeyID:    [4]byte{0x04, 0x88, 0xb2, 0x1e}, // starts with xpub
    50  		GenesisHash:      mustHash("12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2"),
    51  	})
    52  	// TestNet4Params are the clone parameters for testnet.
    53  	TestNet4Params = btc.ReadCloneParams(&btc.CloneParams{
    54  		Name:             "testnet4",
    55  		PubKeyHashAddrID: 0x6f, // starts with m or n
    56  		ScriptHashAddrID: 0x3a, // starts with Q
    57  		Bech32HRPSegwit:  "tltc",
    58  		CoinbaseMaturity: 100,
    59  		Net:              0xf1c8d2fd,
    60  		HDPrivateKeyID:   [4]byte{0x04, 0x35, 0x83, 0x94}, // starts with tprv
    61  		HDPublicKeyID:    [4]byte{0x04, 0x35, 0x87, 0xcf}, // starts with tpub
    62  		GenesisHash:      mustHash("4966625a4b2851d9fdee139e56211a0d88575f59ed816ff5e6a63deb4e3e29a0"),
    63  	})
    64  	// RegressionNetParams are the clone parameters for simnet.
    65  	RegressionNetParams = btc.ReadCloneParams(&btc.CloneParams{
    66  		Name:             "regtest",
    67  		PubKeyHashAddrID: 0x6f, // starts with m or n
    68  		ScriptHashAddrID: 0x3a, // starts with Q
    69  		Bech32HRPSegwit:  "rltc",
    70  		CoinbaseMaturity: 100,
    71  		// Net is not the standard for LTC simnet, since they never changed it
    72  		// from the BTC value. The only place we currently use Net is in
    73  		// btcd/chaincfg.Register, where it is checked to prevent duplicate
    74  		// registration, so our only requirement is that it is unique. This one
    75  		// was just generated with a prng.
    76  		Net:            0x9acb0442,
    77  		HDPrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x94}, // starts with tprv
    78  		HDPublicKeyID:  [4]byte{0x04, 0x35, 0x87, 0xcf}, // starts with tpub
    79  		GenesisHash:    mustHash("530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9"),
    80  	})
    81  )
    82  
    83  func init() {
    84  	for _, params := range []*chaincfg.Params{MainNetParams, TestNet4Params, RegressionNetParams} {
    85  		err := chaincfg.Register(params)
    86  		if err != nil {
    87  			panic("failed to register ltc parameters: " + err.Error())
    88  		}
    89  	}
    90  }