blocktrail-sdk-python icon indicating copy to clipboard operation
blocktrail-sdk-python copied to clipboard

Wallet API implementation

Open rubensayshi opened this issue 10 years ago • 5 comments

** WIP **

test currently fails because delete_wallet requires a signature and there's no python lib implementing this, pending a PR on https://github.com/petertodd/python-bitcoinlib

rubensayshi avatar Feb 24 '15 14:02 rubensayshi

The wallet functionality in this python library will be very useful to me, so be aware of my bias in the following comment: There is currently not much of a dependency on outside code, but this P.R. will introduce a dependency on python-bitcoinlib, which has a dependency on openssl, on recent version of fedora openssl is broken (missing ECC). Im not sure what you mean by signature, but code signing transactions in python is already available, see here: https://github.com/vbuterin/pybitcointools/blob/3213b0a99ab41a06125e45276258437e7ea8d178/bitcoin/transaction.py#L333 , But pardon my ignorance since in delete_wallet i do not expect that its transactions that are being signed. So what exactly do you mean by signature? and who much work would be required to get something done in pure python without pulling in python-bitcoinlib?

thebookworm101 avatar Mar 02 '15 09:03 thebookworm101

Hey @thebookworm101 that's very valuable feedback to know that openssl is broken on fedora!

When you want to delete a wallet you need to use your private key to sign a message to prove you really have the private key, to avoid someone being able to delete a wallet if they get your API key.
So there we need to sign a message with a privatekey, but in a bit of a different way than normal transaction signing (compatible with the signmessage and verifymessage from bitcoind).

I actually tried using pybitcointools and pycoin first before using python-bitcoinlib, the reason for choosing python-bitcoinlib over pybitcointools is that when I tried pybitcointools I ran into a few bugs and I'm also not very comfortable with the relatively low amount of unittests.
And to top it all off it seems that the lead maintainer isn't very active or interested anymore in this library, judging but the activity of commits and the lack of response to the pull requests I did for that library; https://github.com/vbuterin/pybitcointools/pulls

However, if using python-bitcoinlib means that our SDK doesn't work on fedora then I think I'll spend some extra time to see if I can fix the issues in either of the other libraries.

rubensayshi avatar Mar 02 '15 09:03 rubensayshi

Ok, if i get you right then it must be something along these lines: https://github.com/jackjack-jj/jasvet/blob/master/jasvet.py#L479 which i found mentioned here: https://bitcointalk.org/index.php?topic=222992.0 im i thinking what you intended?
If iv got you right i could extract the code (from pybitcointools/this link) into an independent module so it can be used separately.

thebookworm101 avatar Mar 02 '15 12:03 thebookworm101

yea, that's the stuff, nice find!

the biggest problem I see right now is that both pycoin and pybitcointools are very slow in responding to pull requests and for either one of them I will need to do a few pull requests to fix some small bugs they have ...

Another option is adding support for using https://github.com/bitcoin/secp256k1 to python-bitcoinlib, which would probably be the best / coolest solution since then we'll be using the same code as bitcoin core for signing / verying.
The hard part is that users need to build it first ...

rubensayshi avatar Mar 02 '15 14:03 rubensayshi

Its not that hard, especially if we package it together as some libraries do, since setups/pip can do actual builds, this may not be a problem. My biggest worry would be dependencies, and as it stands, python-bitcoinlib's dependency on openssl which is missing ECC on fedora (the tests segfault, its that bad). But also, should you choose to send PRs to one of the two (python-bitcoinlib, pybitcointools) it may have to be one or the other, since they both send up in the same package namespace (https://github.com/vbuterin/pybitcointools/issues/78 ), clobbering each other. Another suggestion for easing users pain in compiling is to create a .deb and .rpm + others for common operating systems.

thebookworm101 avatar Mar 02 '15 17:03 thebookworm101