def cmd_mkwitness(args): tx = None if args.tx is not None: serialized_tx = args.tx tx = CTransaction.deserialize(serialized_tx) else: tx = args.proxy.getrawtransaction(args.txid) txproof = TxProof(tx=tx) for seal_fd in args.seal_fds: seal = BitcoinSingleUseSeal.deserialize(seal_fd.read()) txinproof = None txoutproof = None for i, txin in enumerate(txproof.tx.vin): if txin.prevout == seal.outpoint: txinproof = TxInProof(i=i, txproof=txproof) txoutproof = TxOutProof(i=0, txproof=txproof) break else: args.parser.error("Seal '%s' not closed by this transaction" % seal_fd.name) witness = BitcoinSealWitness(seal=seal, txinproof=txinproof, txoutproof=txoutproof) witness_filename = seal_fd.name + '.witness' logging.info("Creating witness file '%s'" % witness_filename) with open(seal_fd.name + '.witness', 'xb') as witness_fd: witness_fd.write(witness.serialize())
def cmd_mkclosetx(args): seals = collections.OrderedDict() for seal_fd in args.seal_fds: seal = BitcoinSingleUseSeal.deserialize(seal_fd.read()) if seal in seals: args.parser.error("Duplicate seal: '%s' duplicates '%s'" % \ (seal_fd.name, seals[seal].name)) seals[seal] = seal_fd logging.debug('Closing seal %s on outpoint %s:%d' % \ (b2x(seal.hash), b2lx(seal.outpoint.hash), seal.outpoint.n)) seals = seals.keys() close_tx = make_close_seal_tx_template(args.digest, *seals, meth=args.meth) print(b2x(close_tx.serialize()))
def cmd_sealinfo(args): seal = BitcoinSingleUseSeal.deserialize(args.seal_fd.read()) print('Hash:\t\t%s' % b2x(seal.hash)) print('OutPoint:\t%s:%d' % (b2lx(seal.outpoint.hash), seal.outpoint.n))