def __init__(self): CScript.__init__(self) self.project_filename = "" self.glumol_path = "" self.project_path = "" self.normname = "" self.icon = "" self.icon_filename = "" self.debug = False self.optimization = _("None") self.company_name = "" self.company_name = "" self.description = "" self.file_version = 1.0 self.copyrights = "" self.trademark = "" self.product_name = "" self.product_version = 1.0 self.license = "" self.use_upx = False self.use_console = True self.no_single_file = False self.use_tk = False self.eula_path = "" self.readme_path = "" self.templates = [] self.type = "CProject" self.autos = {}
def create_coinbase(heightAdjust=0): global counter coinbase = CTransaction() coinbase.vin.append( CTxIn(COutPoint(0, 0xffffffff), CScript([counter + heightAdjust, OP_0]), 0xffffffff)) counter += 1 coinbaseoutput = CTxOut() coinbaseoutput.nValue = int(5 * 100000000) halvings = int((counter + heightAdjust) / 150) # regtest coinbaseoutput.nValue >>= halvings coinbaseoutput.scriptPubKey = "" coinbase.vout = [coinbaseoutput] if halvings == 0: # regtest froutput = CTxOut() froutput.nValue = coinbaseoutput.nValue / 5 # regtest fraddr = bytearray([ 0x67, 0x08, 0xe6, 0x67, 0x0d, 0xb0, 0xb9, 0x50, 0xda, 0xc6, 0x80, 0x31, 0x02, 0x5c, 0xc5, 0xb6, 0x32, 0x13, 0xa4, 0x91 ]) froutput.scriptPubKey = CScript([OP_HASH160, fraddr, OP_EQUAL]) coinbaseoutput.nValue -= froutput.nValue coinbase.vout = [coinbaseoutput, froutput] coinbase.calc_sha256() return coinbase
def create_coinbase(heightAdjust=0, comm_quota=85): global counter coinbase = CTransaction() coinbase.vin.append( CTxIn(COutPoint(0, 0xffffffff), CScript([counter + heightAdjust, OP_0]), 0xffffffff)) counter += 1 coinbaseoutput = CTxOut() coinbaseoutput.nValue = int(12.5 * 100000000) halvings = int((counter + heightAdjust) / 2000) # regtest coinbaseoutput.nValue >>= halvings coinbaseoutput.scriptPubKey = "" coinbase.vout = [coinbaseoutput] if halvings == 0: # regtest comm_output = CTxOut() comm_output.nValue = (coinbaseoutput.nValue * comm_quota // 1000) # regtest com_addr = bytearray([ 0xb6, 0x86, 0x3b, 0x18, 0x2a, 0x52, 0x74, 0x5b, 0xf6, 0xd5, 0xfb, 0x19, 0x01, 0x39, 0xa2, 0xaa, 0x87, 0x6c, 0x08, 0xf5 ]) comm_output.scriptPubKey = CScript([OP_HASH160, com_addr, OP_EQUAL]) coinbaseoutput.nValue -= comm_output.nValue coinbase.vout.append(comm_output) coinbase.calc_sha256() return coinbase
def __init__(self): CScript.__init__(self) self.project_filename = "" self.glumol_path = "" self.project_path = "" self.normname = "" self.icon = "" self.icon_filename = "" self.debug = False self.optimization = _("None") self.company_name = "" self.company_name = "" self.description = "" self.file_version = 1.0 self.copyrights = "" self.trademark = "" self.product_name = "" self.product_version = 1.0 self.license = "" self.use_upx = False self.use_console = True self.no_single_file = False self.use_tk = False self.eula_path = "" self.readme_path = "" self.templates = [] self.type = "CProject" self.autos = {}
def unDERify(tx): ''' Make the signature in vin 0 of a tx non-DER-compliant, by adding padding after the S-value. ''' scriptSig = CScript(tx.vin[0].scriptSig) newscript = [] for i in scriptSig: if (len(newscript) == 0): newscript.append(i[0:-1] + '\0' + i[-1]) else: newscript.append(i) tx.vin[0].scriptSig = CScript(newscript)
def create_coinbase(height, pubkey = None): coinbase = CTransaction() coinbase.vin.append(CTxIn(COutPoint(0, 0xffffffff), ser_string(serialize_script_num(height)), 0xffffffff)) coinbaseoutput = CTxOut() coinbaseoutput.nValue = 50*100000000 halvings = int(height/150) # regtest coinbaseoutput.nValue >>= halvings if (pubkey != None): coinbaseoutput.scriptPubKey = CScript([pubkey, OP_CHECKSIG]) else: coinbaseoutput.scriptPubKey = CScript([OP_TRUE]) coinbase.vout = [ coinbaseoutput ] coinbase.calc_sha256() return coinbase
def _make_vout(self, pubhash, dsthash, in_amount, amount, fee): from transaction import COut from script import CScript, OP_DUP, OP_HASH160, OP_EQUALVERIFY, OP_CHECKSIG dst_lock_script = CScript( [OP_DUP, OP_HASH160, dsthash, OP_EQUALVERIFY, OP_CHECKSIG]) if amount is None or (amount + fee == in_amount): amount = in_amount - fee return [COut(amount=amount, script=dst_lock_script)], 0, amount else: cashback = in_amount - amount - fee cashback_lock_script = CScript( [OP_DUP, OP_HASH160, pubhash, OP_EQUALVERIFY, OP_CHECKSIG]) return [ COut(amount=cashback, script=cashback_lock_script), COut(amount=amount, script=dst_lock_script) ], cashback, amount
def create_coinbase(heightAdjust=0, absoluteHeight=None, pubkey=None): global counter height = absoluteHeight if absoluteHeight is not None else counter + heightAdjust coinbase = CTransaction() coinbase.vin.append( CTxIn(COutPoint(0, 0xffffffff), ser_string(serialize_script_num(height)), 0xffffffff)) counter += 1 coinbaseoutput = CTxOut() coinbaseoutput.nValue = 50 * 100000000 halvings = int((height) / 150) # regtest coinbaseoutput.nValue >>= halvings if (pubkey != None): coinbaseoutput.scriptPubKey = CScript([pubkey, OP_CHECKSIG]) else: coinbaseoutput.scriptPubKey = CScript([OP_TRUE]) coinbase.vout = [coinbaseoutput] coinbase.calc_sha256() return coinbase
def create_coinbase_h(block_height, halving_interval=2000, heightAdjust=0): subsidy = int(12.5 * 100000000) halvings = int((block_height + heightAdjust) // halving_interval) # 2000 is default for regtest subsidy >>= halvings coinbase = CTransaction() coinbase.vin.append( CTxIn(COutPoint(0, 0xffffffff), CScript([block_height + heightAdjust, OP_0]), 0xffffffff)) coinbaseoutput = CTxOut() coinbaseoutput.nValue = subsidy coinbaseoutput.scriptPubKey = b"" coinbase.vout.append(coinbaseoutput) found, supn, secn = get_coinbase_quotas(block_height) found_out = CTxOut() found_out.nValue = subsidy * found // 1000 found_out.scriptPubKey = CScript([OP_HASH160, found_addr, OP_EQUAL]) coinbaseoutput.nValue -= found_out.nValue coinbase.vout.append(found_out) if supn > 0: supn_out = CTxOut() supn_out.nValue = subsidy * supn // 1000 supn_out.scriptPubKey = CScript([OP_HASH160, supn_addr, OP_EQUAL]) coinbaseoutput.nValue -= supn_out.nValue coinbase.vout.append(supn_out) if secn > 0: secn_out = CTxOut() secn_out.nValue = subsidy * secn // 1000 secn_out.scriptPubKey = CScript([OP_HASH160, secn_addr, OP_EQUAL]) coinbaseoutput.nValue -= secn_out.nValue coinbase.vout.append(secn_out) coinbase.calc_sha256() return coinbase
class CTxOut(object): def __init__(self): self.nValue = -1 self.scriptPubKey = "" def deserialize(self, f): self.nValue = struct.unpack("<q", f.read(8))[0] self.scriptPubKey = deser_string(f) def serialize(self): r = "" r += struct.pack("<q", self.nValue) r += ser_string(self.scriptPubKey) return r def is_valid(self): if self.nValue < 0 or self.nValue > 21000000L * 100000000L: return False script = CScript() if not script.tokenize(self.scriptPubKey): return False return True
def __init__(self, parent=None): CScript.__init__(self, '', parent)
def is_valid(self): script = CScript() if not script.tokenize(self.scriptSig): return False return True
def __init__(self): CScript.__init__(self) self.type = "Dialogue" self.filename = ""
def __init__(self, parent = "None"): CScript.__init__(self, parent) self.type = "CAnimation" self.filename = ""
def __init__(self, parent=None): CScript.__init__(self, '', parent)
def create_tampered_rawtx_cbh(node_from, node_to, tx_amount, fee, mode): genesis_block_hash = node_from.getblock(str(0))['hash'] # select necessary UTXOs usp = node_from.listunspent() assert (len(usp) != 0) amount = Decimal('0') inputs = [] for x in usp: amount += Decimal(x['amount']) inputs.append({"txid": x['txid'], "vout": x['vout']}) if amount >= tx_amount + fee: break outputs = { node_from.getnewaddress(): (Decimal(amount) - tx_amount - fee), node_to.getnewaddress(): tx_amount } rawTx = node_from.createrawtransaction(inputs, outputs) # build an object from the raw Tx in order to be able to modify it tx_01 = CTransaction() f = StringIO(unhexlify(rawTx)) tx_01.deserialize(f) # corrupt vouts in this Tx for vout_idx in range(len(tx_01.vout)): decodedScriptOrig = node_from.decodescript( hexlify(tx_01.vout[vout_idx].scriptPubKey)) scriptOrigAsm = decodedScriptOrig['asm'] params = scriptOrigAsm.split() hash160 = hex_str_to_bytes(params[2]) original_height = int(params[6]) original_hash = hex_str_to_bytes(params[5]) if mode == MODE_HEIGHT: # new referenced block height evil_height = -1 # new referenced block hash modTargetHash = hex_str_to_bytes(swap_bytes(genesis_block_hash)) # build modified script: CScript is putting a 4f (OP_NEGATE) for our -1 # edit script.py to send different stuff for the -1 value (like ff itself!) modScriptPubKey = CScript([ OP_DUP, OP_HASH160, hash160, OP_EQUALVERIFY, OP_CHECKSIG, modTargetHash, evil_height, OP_CHECKBLOCKATHEIGHT ]) elif mode == MODE_SWAP_ARGS: modScriptPubKey = CScript([ OP_DUP, OP_HASH160, hash160, OP_EQUALVERIFY, OP_CHECKSIG, original_height, original_hash, OP_CHECKBLOCKATHEIGHT ]) elif mode == MODE_NON_MIN_ENC: non_min_h = hex_str_to_bytes("07000000") modScriptPubKey = CScript([ OP_DUP, OP_HASH160, hash160, OP_EQUALVERIFY, OP_CHECKSIG, original_hash, non_min_h, OP_CHECKBLOCKATHEIGHT ]) else: assert (False) tx_01.vout[vout_idx].scriptPubKey = modScriptPubKey tx_01.rehash() signedRawTx = node_from.signrawtransaction(ToHex(tx_01)) return signedRawTx
def __init__(self): CScript.__init__(self) self.type = "Dialogue" self.filename = ""
def __init__(self, parent=None): CScript.__init__(self, parent=parent) self.type = "CGlumolObject"
def __init__(self, parent="None"): CScript.__init__(self, parent) self.type = "CAnimation" self.filename = ""
def __init__(self, parent = None): CScript.__init__(self, parent = parent) self.type = "CGlumolObject"
def is_valid(self): script = CScript() if not script.tokenize(self.scriptSig): return False return True