2424
2525# Core definitions
2626COIN = 100000000
27- MAX_MONEY = 21000000 * COIN
2827MAX_BLOCK_SIZE = 1000000
2928MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE / 50
3029
31- def MoneyRange (nValue ):
32- return 0 <= nValue <= MAX_MONEY
30+ def MoneyRange (nValue , params = None ):
31+ global coreparams
32+ if not params :
33+ params = coreparams
34+
35+ return 0 <= nValue <= params .MAX_MONEY
3336
3437def _py2_x (h ):
3538 """Convert a hex string to bytes"""
@@ -537,12 +540,14 @@ def GetHash(self):
537540
538541class CoreChainParams (object ):
539542 """Define consensus-critical parameters of a given instance of the Bitcoin system"""
543+ MAX_MONEY = None
540544 GENESIS_BLOCK = None
541545 PROOF_OF_WORK_LIMIT = None
542546 SUBSIDY_HALVING_INTERVAL = None
543547 NAME = None
544548
545549class CoreMainParams (CoreChainParams ):
550+ MAX_MONEY = 21000000 * COIN
546551 NAME = 'mainnet'
547552 GENESIS_BLOCK = CBlock .deserialize (x ('0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c0101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000' ))
548553 SUBSIDY_HALVING_INTERVAL = 210000
@@ -586,6 +591,7 @@ def CheckTransaction(tx):
586591
587592 Raises CheckTransactionError
588593 """
594+ global coreparams
589595
590596 if not tx .vin :
591597 raise CheckTransactionError ("CheckTransaction() : vin empty" )
@@ -601,7 +607,7 @@ def CheckTransaction(tx):
601607 for txout in tx .vout :
602608 if txout .nValue < 0 :
603609 raise CheckTransactionError ("CheckTransaction() : txout.nValue negative" )
604- if txout .nValue > MAX_MONEY :
610+ if txout .nValue > coreparams . MAX_MONEY :
605611 raise CheckTransactionError ("CheckTransaction() : txout.nValue too high" )
606612 nValueOut += txout .nValue
607613 if not MoneyRange (nValueOut ):
@@ -737,7 +743,6 @@ def CheckBlock(block, fCheckPoW = True, fCheckMerkleRoot = True, cur_time=None):
737743 'Hash' ,
738744 'Hash160' ,
739745 'COIN' ,
740- 'MAX_MONEY' ,
741746 'MAX_BLOCK_SIZE' ,
742747 'MAX_BLOCK_SIGOPS' ,
743748 'MoneyRange' ,
0 commit comments