decred.org/dcrdex@v1.0.5/dex/networks/doge/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 doge
     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  const (
    14  	// The default fee is passed to the user as part of the asset.WalletInfo
    15  	// structure. For details on DOGE-specific limits, see:
    16  	// https://github.com/dogecoin/dogecoin/blob/master/doc/fee-recommendation.md
    17  	// and https://github.com/dogecoin/dogecoin/discussions/2347
    18  	// Dogecoin Core v1.14.5 adopts proposed fees for tx creation:
    19  	// https://github.com/dogecoin/dogecoin/releases/tag/v1.14.5
    20  	// https://github.com/dogecoin/dogecoin/commit/9c6af6d84179e46002338bb5b9a69c6f2367c731
    21  	// These limits were applied to mining and relay in v1.14.4.
    22  	DefaultFee          = 4_000  // 0.04 DOGE/kB, 4x the 0.01 recommended by dogecoin core (DEFAULT_TRANSACTION_FEE)
    23  	DefaultFeeRateLimit = 50_000 // 0.5 DOGE/kB, where v1.14.5 considers 1.0 DOGE/kB "high" (HIGH_TX_FEE_PER_KB)
    24  )
    25  
    26  func mustHash(hash string) *chainhash.Hash {
    27  	h, err := chainhash.NewHashFromStr(hash)
    28  	if err != nil {
    29  		panic(err.Error())
    30  	}
    31  	return h
    32  }
    33  
    34  var (
    35  	UnitInfo = dex.UnitInfo{
    36  		AtomicUnit: "Sats",
    37  		Conventional: dex.Denomination{
    38  			Unit:             "DOGE",
    39  			ConversionFactor: 1e8,
    40  		},
    41  		Alternatives: []dex.Denomination{
    42  			{
    43  				Unit:             "mDOGE",
    44  				ConversionFactor: 1e5,
    45  			},
    46  			{
    47  				Unit:             "µDOGE",
    48  				ConversionFactor: 1e2,
    49  			},
    50  		},
    51  		FeeRateDenom: "vB",
    52  	}
    53  
    54  	// MainNetParams are the clone parameters for mainnet.
    55  	MainNetParams = btc.ReadCloneParams(&btc.CloneParams{
    56  		Name:             "mainnet",
    57  		PubKeyHashAddrID: 0x1e,
    58  		ScriptHashAddrID: 0x16,
    59  		CoinbaseMaturity: 30,
    60  		Net:              0xc0c0c0c0,
    61  		GenesisHash:      mustHash("1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691"),
    62  	})
    63  	// TestNet4Params are the clone parameters for testnet.
    64  	TestNet4Params = btc.ReadCloneParams(&btc.CloneParams{
    65  		Name:             "testnet4",
    66  		PubKeyHashAddrID: 0x71,
    67  		ScriptHashAddrID: 0xc4,
    68  		CoinbaseMaturity: 30,
    69  		Net:              0xfcc1b7dc,
    70  		GenesisHash:      mustHash("bb0a78264637406b6360aad926284d544d7049f45189db5664f3c4d07350559e"),
    71  	})
    72  	// RegressionNetParams are the clone parameters for simnet.
    73  	RegressionNetParams = btc.ReadCloneParams(&btc.CloneParams{
    74  		Name:             "regtest",
    75  		PubKeyHashAddrID: 0x6f,
    76  		ScriptHashAddrID: 0xc4,
    77  		CoinbaseMaturity: 60,
    78  		// Net is not the standard for DOGE simnet, since they never changed it
    79  		// from the BTC value. The only place we currently use Net is in
    80  		// btcd/chaincfg.Register, where it is checked to prevent duplicate
    81  		// registration, so our only requirement is that it is unique. This one
    82  		// was just generated with a prng.
    83  		Net:         0xf97c5a97,
    84  		GenesisHash: nil, // TODO or unused with simnet?
    85  	})
    86  )
    87  
    88  func init() {
    89  	for _, params := range []*chaincfg.Params{MainNetParams, TestNet4Params, RegressionNetParams} {
    90  		err := chaincfg.Register(params)
    91  		if err != nil {
    92  			panic("failed to register doge parameters: " + err.Error())
    93  		}
    94  	}
    95  }