stacks-network / pybitcoin

A Bitcoin python library for private + public keys, addresses, transactions, & RPC
MIT License
277 stars 117 forks source link

serialize_sign_and_broadcast only signs the first input #40

Open peacekeeper opened 9 years ago

peacekeeper commented 9 years ago

in serialize_sign_and_broadcast() in transactions/network.py, sign_transaction() is only called on the first input (index 0):

def serialize_sign_and_broadcast(inputs, outputs, private_key,
                                 blockchain_client=BlockchainInfoClient()):
    # extract the private key object
    private_key_obj = get_private_key_obj(private_key)
    # serialize the transaction
    unsigned_tx = serialize_transaction(inputs, outputs)
    # sign the unsigned transaction with the private key
    signed_tx = sign_transaction(unsigned_tx, 0, private_key_obj.to_hex())
    # dispatch the signed transction to the network
    response = broadcast_transaction(signed_tx, blockchain_client)
    # return the response
    return response

therefore transactions that require multiple inputs become invalid

jcnelson commented 9 years ago

Hi @peacekeeper,

This problem has been fixed in my branch (https://github.com/blockstack/pybitcoin/tree/jcnelson-master).