Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't Transaction btc #11

Closed
reynoldxu opened this issue Mar 9, 2014 · 6 comments
Closed

can't Transaction btc #11

reynoldxu opened this issue Mar 9, 2014 · 6 comments

Comments

@reynoldxu
Copy link

Hi,I;m just try pybitcointools but when i try to send btc to another address,it failed

I replaced priv = '???' instead sha256('some big long brainwallet password'),but error occoured when the 3rd sign as following:

tx3 = sign(tx2,1,priv)
  File "C:\Python27\lib\site-packages\pybitcointools\transaction.py", line 252, in sign
    signing_tx = signature_form(tx,i,mk_pubkey_script(address))
  File "C:\Python27\lib\site-packages\pybitcointools\transaction.py", line 104, in signature_form
    return serialize(signature_form(deserialize(tx),i,script))
  File "C:\Python27\lib\site-packages\pybitcointools\transaction.py", line 107, in signature_form
    newtx["ins"][i]["script"] = script
IndexError: list index out of range

i'm confused about sign(tx,i,priv),but i think according to the example ,the Index is correct,where's the problem?

The btc address is 1CtpwCtuWh7puJFkvXYMZNWaFD9rdG4YrT

Thanks,

reynolds

@reynoldxu
Copy link
Author

seems that the priv key is not right and cant import into bitcoin-qt

>>> priv = sha256('hello_xmh@shnu')
>>> priv
'1af56f41c4edf512d4b76e2f9be72966fc1c81324adcf6d13036fd0c12f7121a'
>>> pub = privtopub(priv)
>>> pub
'047b06a864fd0fd3f73b5f14cfd0c56f0b5519d05b6cc0b0d3f9dc5bd637001c723548aa4fc5b60c466bb6cd7dd83379ce2d93fbf383b7f8541719aee156d83760'
>>> addr = pubtoaddr(pub)
>>> addr
'1Pih9FmU3HN7JseN3Ca4reuq6ds1qvX6gx'
>>> 

failed to import priv key to bitcoin-qt


16:29:57

importprivkey 1af56f41c4edf512d4b76e2f9be72966fc1c81324adcf6d13036fd0c12f7121a


16:29:57

Invalid private key (code -5)

when i use the priv key to send btc ,failed ,the same:

>>> h = history(addr)
>>> h
[{'output': u'914bd4c98c944a280f59d48841797a95cc1f402ef400e7e9d392e67feb67c899:1', 'block_height': 289844, 'value': 100000, 'address': u'1Pih9FmU3HN7JseN3Ca4reuq6ds1qvX6gx'}]
>>> outs = [{'value': 1000, 'address': '1NLndq3B15EfGv8GQthxhDzFNQGPbsWQyg'}]
>>> tx = mktx(h,outs)
>>> tx2 = sign(tx,0,priv)
>>> tx3 = sign(tx2,1,priv)

Traceback (most recent call last):
  File "<pyshell#11>", line 1, in <module>
    tx3 = sign(tx2,1,priv)
  File "C:\Python27\lib\site-packages\pybitcointools\transaction.py", line 252, in sign
    signing_tx = signature_form(tx,i,mk_pubkey_script(address))
  File "C:\Python27\lib\site-packages\pybitcointools\transaction.py", line 104, in signature_form
    return serialize(signature_form(deserialize(tx),i,script))
  File "C:\Python27\lib\site-packages\pybitcointools\transaction.py", line 107, in signature_form
    newtx["ins"][i]["script"] = script
IndexError: list index out of range

@reynoldxu
Copy link
Author

well,the priv key should be convert to WIF formart than it could be import into bitcoin-qt.

working on the error:

tx3 = sign(tx2,1,priv)

newtx["ins"][i]["script"] = script
IndexError: list index out of range

@vbuterin
Copy link
Owner

Can you give me the tx that you're signing? Maybe the transaction doesn't have two inputs (inputs are zero-indexed so the first input is really input 0).

@reynoldxu
Copy link
Author

Yes, it has only one inputs(i use a new address for test so ,it has only one input)
Tx bin is
010000000199c867eb7fe692d3e9e700f42e401fcc957a794188d4590f284a948cc9d44b910100000000ffffffff01e8030000000000001976a914ea18a38e2119616d05fbb31a2138f43565608d7c88ac00000000
Tx json is
{'locktime': 0, 'outs': [{'value': 1000, 'script': '76a914ea18a38e2119616d05fbb31a2138f43565608d7c88ac'}], 'version': 1, 'ins': [{'script': '', 'outpoint': {'index': 1, 'hash': '914bd4c98c944a280f59d48841797a95cc1f402ef400e7e9d392e67feb67c899'}, 'sequence': 4294967295L}]}

@vbuterin
Copy link
Owner

All done!

vub@shadowcow-200 13:26:50 Bitcoin/bitcoin: ./pybtctool sign 010000000199c867eb7fe692d3e9e700f42e401fcc957a794188d4590f284a948cc9d44b910100000000ffffffff01e8030000000000001976a914ea18a38e2119616d05fbb31a2138f43565608d7c88ac00000000 0 1af56f41c4edf512d4b76e2f9be72966fc1c81324adcf6d13036fd0c12f7121a
010000000199c867eb7fe692d3e9e700f42e401fcc957a794188d4590f284a948cc9d44b91010000008a47304402207a4034f13ba188b35e72e7a2bb5328a5b89ae89f9c5aacd021aeca33a91f25f602207b7ef2142edf506d1331e4627b8eec874faf0bc6fa010c6da47ba951c40a5b320141047b06a864fd0fd3f73b5f14cfd0c56f0b5519d05b6cc0b0d3f9dc5bd637001c723548aa4fc5b60c466bb6cd7dd83379ce2d93fbf383b7f8541719aee156d83760ffffffff01e8030000000000001976a914ea18a38e2119616d05fbb31a2138f43565608d7c88ac00000000
vub@shadowcow-200 13:28:53 Bitcoin/bitcoin: ./pybtctool sign 010000000199c867eb7fe692d3e9e700f42e401fcc957a794188d4590f284a948cc9d44b910100000000ffffffff01e8030000000000001976a914ea18a38e2119616d05fbb31a2138f43565608d7c88ac00000000 0 1af56f41c4edf512d4b76e2f9be72966fc1c81324adcf6d13036fd0c12f7121a | pybtctool -s pushtx
Transaction Submitted

@reynoldxu
Copy link
Author

I understand,thanks .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants