Skip to content

Instantly share code, notes, and snippets.

@johnta0
Last active April 13, 2018 07:04
Show Gist options
  • Save johnta0/693e0c9bd10e9836827c59bc43422f09 to your computer and use it in GitHub Desktop.
Save johnta0/693e0c9bd10e9836827c59bc43422f09 to your computer and use it in GitHub Desktop.
import bitcoin
def sign_all_ins(unsigned_tx, priv, nb_ins=None):
utxo = nb_ins
if utxo == None:
utxo = len(bitcoin.unspent(bitcoin.privtoaddr(priv)))
for i in range(utxo):
signed_tx = bitcoin.sign(unsigned_tx, i, priv)
return signed_tx
if __name__ == '__main__':
HEX = raw_input("Input previous txid(transaction hash).")
PRIVATE_KEY = raw_input("Input private key.")
deserialize_hex = bitcoin.deserialize(HEX)
ins = deserialize_hex['ins']
signed_tx = sign_all_ins(HEX, PRIVATE_KEY, len(ins))
print(signed_tx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment