decred.org/dcrdex@v1.0.5/dex/networks/dgb/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 dgb
     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  	// DEFAULT_TRANSACTION_MINFEE is 100 (mintxfee default is 0.001 DGB/kB)
    15  	// DEFAULT_DISCARD_FEE is 10 (minrelaytxfee and blockmintxfee defaults are 0.00001 DGB/kB)
    16  	// HIGH_TX_FEE_PER_KB is 100,000 (1 DGB/kB), warning level
    17  	// DEFAULT_TRANSACTION_MAXFEE is 100,000 (maxtxfee default is 0.1 DGB/kB)
    18  	DefaultFee          = 200  // 0.002 DGB/kB
    19  	DefaultFeeRateLimit = 5000 // 0.05 DGB/kB
    20  )
    21  
    22  // v7.17.4 defaults:
    23  // -fallbackfee= (default: 0.0002) fee estimation fallback
    24  // -mintxfee= (default: 0.001)  for tx creation
    25  // -maxtxfee= (default: 1.00)
    26  // -minrelaytxfee= (default: 0.00001)
    27  // -blockmintxfee= (default: 0.00001)
    28  
    29  func mustHash(hash string) *chainhash.Hash {
    30  	h, err := chainhash.NewHashFromStr(hash)
    31  	if err != nil {
    32  		panic(err.Error())
    33  	}
    34  	return h
    35  }
    36  
    37  var (
    38  	UnitInfo = dex.UnitInfo{
    39  		AtomicUnit: "digiSatoshi",
    40  		Conventional: dex.Denomination{
    41  			Unit:             "DGB",
    42  			ConversionFactor: 1e8,
    43  		},
    44  		Alternatives: []dex.Denomination{
    45  			{
    46  				Unit:             "mDGB",
    47  				ConversionFactor: 1e5,
    48  			},
    49  			{
    50  				Unit:             "µDGB",
    51  				ConversionFactor: 1e2,
    52  			},
    53  		},
    54  		FeeRateDenom: "vB",
    55  	}
    56  
    57  	// MainNetParams are the clone parameters for mainnet.
    58  	MainNetParams = btc.ReadCloneParams(&btc.CloneParams{
    59  		Name:             "mainnet",
    60  		PubKeyHashAddrID: 0x1e, // 30 - start with D
    61  		ScriptHashAddrID: 0x3f, // 63 - start with S, "old" was 5
    62  		Bech32HRPSegwit:  "dgb",
    63  		CoinbaseMaturity: 100, // 8 before block "multiAlgoDiffChangeTarget" (145000)
    64  		Net:              0xfac3b6da,
    65  		GenesisHash:      mustHash("7497ea1b465eb39f1c8f507bc877078fe016d6fcb6dfad3a64c98dcc6e1e8496"),
    66  	})
    67  	// TestNetParams are the clone parameters for testnet.
    68  	TestNetParams = btc.ReadCloneParams(&btc.CloneParams{
    69  		Name:             "testnet4",
    70  		PubKeyHashAddrID: 0x7e, // 126 - start with t
    71  		ScriptHashAddrID: 0x8c, // 140 - start with s
    72  		Bech32HRPSegwit:  "dgbt",
    73  		CoinbaseMaturity: 100,
    74  		Net:              0xfdc8bddd,
    75  		GenesisHash:      mustHash("308ea0711d5763be2995670dd9ca9872753561285a84da1d58be58acaa822252"),
    76  	})
    77  	// RegressionNetParams are the clone parameters for simnet.
    78  	RegressionNetParams = btc.ReadCloneParams(&btc.CloneParams{
    79  		Name:             "regtest",
    80  		PubKeyHashAddrID: 0x7e, // 126
    81  		ScriptHashAddrID: 0x8c, // 140
    82  		Bech32HRPSegwit:  "dgbrt",
    83  		CoinbaseMaturity: 100,
    84  		// Net is not the standard for DGB simnet, since they never changed it
    85  		// from the BTC value. The only place we currently use Net is in
    86  		// btcd/chaincfg.Register, where it is checked to prevent duplicate
    87  		// registration, so our only requirement is that it is unique. This one
    88  		// was just generated with a prng.
    89  		Net:         0xfa55b279,
    90  		GenesisHash: mustHash("4598a0f2b823aaf9e77ee6d5e46f1edb824191dcd48b08437b7cec17e6ae6e26"), // TODO or unused with simnet?
    91  	})
    92  )
    93  
    94  func init() {
    95  	for _, params := range []*chaincfg.Params{MainNetParams, TestNetParams, RegressionNetParams} {
    96  		err := chaincfg.Register(params)
    97  		if err != nil {
    98  			panic("failed to register dgb parameters: " + err.Error())
    99  		}
   100  	}
   101  }