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())