How can I sign transaction hex with Python library

I have a unsigned transaction hex. Now I want to sign this transaction input with my private key in Python. Are there any Python libraries?

Transaction Hex


Decoded Transaction

{    "txid":"6c521937d8fa889d71609ebed2e23b694cbca89778c8b8d967167e5a4c9d5b78",    "size":381,    "version":1,    "locktime":0,    "vin":[       {          "txid":"459eee043d30b29c4f9e9b3b55af78f5b4fe4bd818bee49a4b75becd6422ae14",          "vout":0,          "scriptSig":{             "asm":"OP_DUP OP_HASH160 58b6e991b45487df810f4d96d5315da739637f17 OP_EQUALVERIFY OP_CHECKSIG",             "hex":"76a91458b6e991b45487df810f4d96d5315da739637f1788ac"          },          "sequence":4294967295       },       {          "txid":"621c6b92cc2c68b18fef3a90a3284d1263ea43e0cbce21d9ef6f51747bd215ec",          "vout":0,          "scriptSig":{             "asm":"OP_DUP OP_HASH160 58b6e991b45487df810f4d96d5315da739637f17 OP_EQUALVERIFY OP_CHECKSIG",             "hex":"76a91458b6e991b45487df810f4d96d5315da739637f1788ac"          },          "sequence":4294967295       },       {          "txid":"92a271c568aea34c3e2661db9b8fc7f0d82d90065db1b6eed1c124146ef77898",          "vout":0,          "scriptSig":{             "asm":"OP_DUP OP_HASH160 58b6e991b45487df810f4d96d5315da739637f17 OP_EQUALVERIFY OP_CHECKSIG",             "hex":"76a91458b6e991b45487df810f4d96d5315da739637f1788ac"          },          "sequence":4294967295       },       {          "txid":"99c43b144adb6d114180c11f26bc08264c806b355d96a824891ab0831c7facfd",          "vout":0,          "scriptSig":{             "asm":"OP_DUP OP_HASH160 58b6e991b45487df810f4d96d5315da739637f17 OP_EQUALVERIFY OP_CHECKSIG",             "hex":"76a91458b6e991b45487df810f4d96d5315da739637f1788ac"          },          "sequence":4294967295       }    ],    "vout":[       {          "value":5.43e-5,          "n":0,          "scriptPubKey":{             "asm":"OP_DUP OP_HASH160 1485d9d03b41aaa9dca7d70d7f63ff4a0826100e OP_EQUALVERIFY OP_CHECKSIG",             "hex":"76a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88ac",             "reqSigs":1,             "type":"pubkeyhash",             "addresses":[                "12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD"             ]          }       },       {          "value":0,          "n":1,          "scriptPubKey":{             "asm":"OP_RETURN 246698efc5d81b78ceadf3179316b5eb6cc5c2c347c0b7b42121a94e",             "hex":"6a1c246698efc5d81b78ceadf3179316b5eb6cc5c2c347c0b7b42121a94e",             "type":"nulldata"          }       },       {          "value":6.29e-5,          "n":2,          "scriptPubKey":{             "asm":"OP_DUP OP_HASH160 58b6e991b45487df810f4d96d5315da739637f17 OP_EQUALVERIFY OP_CHECKSIG",             "hex":"76a91458b6e991b45487df810f4d96d5315da739637f1788ac",             "reqSigs":1,             "type":"pubkeyhash",             "addresses":[                "1965areciqapsuL2hsia2yKkRLfAsH1smG"             ]          }       }    ] } 

Recent Questions – Bitcoin Stack Exchange

Bitcoin Core Developer Eric Lombrozo reflects on the Ethereum Classic situation, as it relates to the choices facing the Bitcoin community.

Think of the chain of events in Ethereum: a problem with reentrancy in EVM led to funds getting sucked out of a contract tied to insiders, which led to a transaction reversal, which led to a fork, which led to a split of the ethereum community and network.

And that’s the thing about these attacks – you don’t see them coming until it’s too late.

And the weakest link in all this are not computers, but people.

Things like the block size debate are like kids arguing about what to get in a candy store as it’s burning down, and then complaining that you won’t let them taste the candy.

These networks operate in adversarial conditions. A very tiny region within the entire space of possibilities leads to something that continues to work the way you want (if at all).

This is why throwing darts is probably not the best strategy.

Moreover, the kinds of unwanted things that result are likely to be surprising and unexpected. It’s the nature of adversarial computing environments.

submitted by /u/eragmus
[link] [comments]

Are there any legit ways to earn interest on bitcoin yet?

I've been prospecting against my local currency with some success for a while now, but it takes time and dedication that I don't have in the next few months. I've been wondering if there are any funds etc yet where interest can be earned, or is it all still just ponzi schemes or scams? I googled around and found magnr and bitbays, and I can't figure out how legit these guys are and if there is any one else trustworthy in the space.

submitted by /u/_imba__
[link] [comments]

Troubleshooting pybitcointools transaction signing/verification

I’m having several problems getting tests to successfully run under my fork (or vbuterin’s pybitcointools, and I’m hoping someone with a combined Python / Bitcoin knowledge can provide some insight.

Here’s the error message (as submitted to #145):

====================================================================== FAIL: test_all (__main__.TestTransaction) ---------------------------------------------------------------------- Traceback (most recent call last):   File "/private/var/mobile/Containers/Shared/AppGroup/AA78F2EC-3EE8-40F4-A318-8A9AB1BCB5FF/Pythonista3/Documents/pybitcointools-vbuterin/", line 179, in test_all     self.assertTrue(verify_tx_input(tx1, 0, mscript, sig1, pubs[1]), "Verification Error") AssertionError: Verification Error  ====================================================================== FAIL: test_all (__main__.TestTransactionSignVerify) ---------------------------------------------------------------------- Traceback (most recent call last):   File "/private/var/mobile/Containers/Shared/AppGroup/AA78F2EC-3EE8-40F4-A318-8A9AB1BCB5FF/Pythonista3/Documents/pybitcointools-vbuterin/", line 133, in test_all     "Verification error" AssertionError: Verification error  ---------------------------------------------------------------------- Ran 18 tests in 6.944s  FAILED (failures=2, errors=2) 

I’ve got a hunch this has to do with the introduction of low_s (ie s = N-s if s>N//2 else s) for ECDSA signing, but can’t be certain.

Can anyone point out where things are going astray?

Recent Questions – Bitcoin Stack Exchange