def makeCoinbaseTxn(coinbaseValue, useCoinbaser = True): txn = Txn.new() if useCoinbaser and hasattr(config, 'CoinbaserCmd') and config.CoinbaserCmd: coinbased = 0 try: cmd = config.CoinbaserCmd cmd = cmd.replace('%d', str(coinbaseValue)) p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) nout = int(p.stdout.readline()) for i in range(nout): amount = int(p.stdout.readline()) addr = p.stdout.readline().rstrip(b'\n').decode('utf8') pkScript = BitcoinScript.toAddress(addr) txn.addOutput(amount, pkScript) coinbased += amount except: coinbased = coinbaseValue + 1 if coinbased >= coinbaseValue: logging.getLogger('makeCoinbaseTxn').error('Coinbaser failed!') txn.outputs = [] else: coinbaseValue -= coinbased pkScript = BitcoinScript.toAddress(config.TrackerAddr) txn.addOutput(coinbaseValue, pkScript) # TODO # TODO: red flag on dupe coinbase return txn
def makeCoinbaseTxn(coinbaseValue, useCoinbaser = True): txn = Txn.new() if useCoinbaser and hasattr(config, 'CoinbaserCmd') and config.CoinbaserCmd: coinbased = 0 try: cmd = config.CoinbaserCmd cmd = cmd.replace('%d', str(coinbaseValue)) p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) nout = int(p.stdout.readline()) for i in range(nout): amount = int(p.stdout.readline()) addr = p.stdout.readline().rstrip(b'\n').decode('utf8') pkScript = BitcoinScript.toAddress(addr) txn.addOutput(amount, pkScript) coinbased += amount except: coinbased = coinbaseValue + 1 if coinbased >= coinbaseValue: logging.getLogger('makeCoinbaseTxn').error('Coinbaser failed!') txn.outputs = [] else: coinbaseValue -= coinbased pkScript = BitcoinScript.toAddress(config.TrackerAddr) txn.addOutput(coinbaseValue, pkScript) # TODO # TODO: red flag on dupe coinbase return txn
def makeCoinbaseTxn(coinbaseValue, useCoinbaser=True, prevBlockHex=None, witness_commitment=NotImplemented): if witness_commitment is NotImplemented: raise NotImplementedError txn = Txn.new() #todo needs get dev rewared from MP pkScript = BitcoinScript.toAddress(config.TrackerAddr) devfeeScript = BitcoinScript.toAddress(config.Coinbaser_fee) txn.addOutput(coinbaseValue - config.Coinbaser_value, pkScript) txn.addOutput(config.Coinbaser_value, devfeeScript) txn.addOutput(config.devreward_value, a2b_hex(config.devreward_pubkey)) # SegWit commitment if not witness_commitment is None: txn.addOutput( 0, BitcoinScript.commitment(WitnessMagic + witness_commitment)) # TODO # TODO: red flag on dupe coinbase return txn
def makeCoinbaseTxn(coinbaseValue, useCoinbaser=True, prevBlockHex=None, witness_commitment=NotImplemented, rsk_blockhash=None): if witness_commitment is NotImplemented: raise NotImplementedError txn = Txn.new() if useCoinbaser and hasattr(config, 'CoinbaserCmd') and config.CoinbaserCmd: coinbased = 0 try: cmd = config.CoinbaserCmd cmd = cmd.replace('%d', str(coinbaseValue)) cmd = cmd.replace('%p', prevBlockHex or '""') p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) nout = int(p.stdout.readline()) for i in range(nout): amount = int(p.stdout.readline()) addr = p.stdout.readline().rstrip(b'\n').decode('utf8') pkScript = BitcoinScript.toAddress(addr) txn.addOutput(amount, pkScript) coinbased += amount except: coinbased = coinbaseValue + 1 if coinbased >= coinbaseValue: logging.getLogger('makeCoinbaseTxn').error('Coinbaser failed!') txn.outputs = [] else: coinbaseValue -= coinbased pkScript = BitcoinScript.toAddress(config.TrackerAddr) txn.addOutput(coinbaseValue, pkScript) # SegWit commitment if not witness_commitment is None: txn.addOutput( 0, BitcoinScript.commitment(WitnessMagic + witness_commitment)) # RSK merged mining if rsk_blockhash is not None: txn.addOutput(0, rootstock.getRSKTag() + rsk_blockhash) # TODO # TODO: red flag on dupe coinbase return txn
def makeCoinbaseTxn(coinbaseValue, useCoinbaser = True, prevBlockHex = None, witness_commitment = NotImplemented): if witness_commitment is NotImplemented: raise NotImplementedError txn = Txn.new() if useCoinbaser and hasattr(config, 'CoinbaserCmd') and config.CoinbaserCmd: coinbased = 0 try: cmd = config.CoinbaserCmd cmd = cmd.replace('%d', str(coinbaseValue)) cmd = cmd.replace('%p', prevBlockHex or '""') p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) nout = int(p.stdout.readline()) for i in range(nout): amount = int(p.stdout.readline()) addr = p.stdout.readline().rstrip(b'\n').decode('utf8') pkScript = BitcoinScript.toAddress(addr) txn.addOutput(amount, pkScript) coinbased += amount except: coinbased = coinbaseValue + 1 if coinbased >= coinbaseValue: logging.getLogger('makeCoinbaseTxn').error('Coinbaser failed!') txn.outputs = [] else: coinbaseValue -= coinbased pkScript = BitcoinScript.toAddress(config.TrackerAddr) txn.addOutput(coinbaseValue, pkScript) # SegWit commitment if not witness_commitment is None: txn.addOutput(0, BitcoinScript.commitment(WitnessMagic + witness_commitment)) # TODO # TODO: red flag on dupe coinbase return txn