Пример #1
0
def vote_init(vote: Vote, inputs: dict, change_address: str) -> bytes:
    '''initialize vote transaction, must be signed by the deck_issuer privkey'''

    network_params = net_query(vote.deck.network)
    deck_vote_tag_address = deck_vote_tag(vote.deck)

    tx_fee = network_params.min_tx_fee  # settle for min tx fee for now

    for utxo in inputs['utxos']:
        utxo['txid'] = unhexlify(utxo['txid'])
        utxo['scriptSig'] = unhexlify(utxo['scriptSig'])

    outputs = [{
        "redeem":
        0.01,
        "outputScript":
        transactions.monosig_script(deck_vote_tag_address)
    }, {
        "redeem": 0,
        "outputScript": transactions.op_return_script(vote.to_protobuf)
    }, {
        "redeem": float(inputs['total']) - float(tx_fee) - float(0.01),
        "outputScript": transactions.monosig_script(change_address)
    }]

    return transactions.make_raw_transaction(inputs['utxos'], outputs)
Пример #2
0
def vote_cast(vote: Vote, choice_index: int, inputs: dict,
              change_address: str) -> bytes:
    '''vote cast transaction'''

    network_params = net_query(vote.deck.network)
    vote_cast_addr = vote.vote_choice_address[choice_index]

    tx_fee = network_params.min_tx_fee  # settle for min tx fee for now

    for utxo in inputs['utxos']:
        utxo['txid'] = unhexlify(utxo['txid'])
        utxo['scriptSig'] = unhexlify(utxo['scriptSig'])

    outputs = [{
        "redeem": 0.01,
        "outputScript": transactions.monosig_script(vote_cast_addr)
    }, {
        "redeem": float(inputs['total']) - float(tx_fee) - float(0.01),
        "outputScript": transactions.monosig_script(change_address)
    }]

    return transactions.make_raw_transaction(inputs['utxos'], outputs)