Example #1
0
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())
Example #2
0
def cmd_witnessinfo(args):
    witness = BitcoinSealWitness.deserialize(args.witness_fd.read())

    print('Hash:\t\t%s' % b2x(witness.hash))
    print('Txid:\t\t%s' % b2lx(witness.txinproof.txproof.txhash))
    print('Seal Hash:\t%s' % b2x(witness.seal.hash))
    print('Seal OutPoint:\t%s:%d' % (b2x(witness.seal.outpoint.hash), witness.seal.outpoint.n))
Example #3
0
def cmd_verifywitness(args):
    witness = BitcoinSealWitness.deserialize(args.witness_fd.read())

    # FIXME: implement --local
    witness.verify()

    if args.digest is not None:
        witness.verify_hash(args.digest)