def push_tx(self, tx_signed): # push transactions requires a post to blockr path = '/tx/push' url = self._url + path payload = {'hex': tx_signed} response = requests.post(url, data=payload) return pybitcointools.txhash(tx_signed)
def push(self, tx): """ Args: tx: hex of signed transaction Returns: pushed transaction """ self._service.push_tx(tx) return pybitcointools.txhash(tx)
def dump_tx_ecdsa(txid, i): tx = getrawtx(txid) vin = tx['vin'][i] if 'coinbase' in vin: return prev_tx = getrawtx(vin['txid']) prev_vout = prev_tx['vout'][vin['vout']] prev_type = prev_vout['scriptPubKey']['type'] script = prev_vout['scriptPubKey']['hex'] if prev_type == 'pubkeyhash': sig, pub = vin['scriptSig']['asm'].split(' ') elif prev_type == 'pubkey': sig = vin['scriptSig']['asm'] pub, _ = prev_vout['scriptPubKey']['asm'].split(' ') else: logger.warning("%6d %s %4d ERROR_UNHANDLED_SCRIPT_TYPE" % (txid, i)) raise x = pub[2:66] #print sig if sig[-1] == ']': sig, hashcode_txt = sig.strip(']').split('[') if hashcode_txt == 'ALL': hashcode = 1 elif hashcode_txt == 'SINGLE': hashcode = 3 else: print hashcode_txt logger.warning("xx %s %4d ERROR_UNHANDLED_HASHCODE" % (txid, hashcode_txt)) raise else: hashcode = int(sig[-2:], 16) sig = sig[:-2] modtx = pybitcointools.serialize( pybitcointools.signature_form(pybitcointools.deserialize(tx['hex']), i, script, hashcode)) z = hexlify(pybitcointools.txhash(modtx, hashcode)) _, r, s = pybitcointools.der_decode_sig(sig) r = pybitcointools.encode(r, 16, 64) s = pybitcointools.encode(s, 16, 64) #print verify_tx_input(tx['hex'], i, script, sig, pub) return {'txid': txid, 'i': i, 'x': x, 'r': r, 's': s, 'z': z, 'pub': pub}
def push(self, tx): self._service.push_tx(tx) return pybitcointools.txhash(tx)