-
Notifications
You must be signed in to change notification settings - Fork 23
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
Bitcoind rpc wrapper #4
Bitcoind rpc wrapper #4
Conversation
includes: -doc for —rpc switch -editor smashed some trailing whitespace, sorry! -troubleshooting for users of python2/3 -instruction for using different data sources
some trailing whitespace clobbering by editor — sorry
I've done a quick review. It seems to work fine for the cases covered with the bc.i api. Here are a few remarks : BitcoindRPCWrapper._get_decoded_tx() You can replace this line
by
It returns the information needed and it removes an extra call to the rpc api. BitcoindRPCWrapper._get_block_height() Considering that the block height isn't required for the computation of the metrics and that the method will often return a warning because the outputs were consumed, I think it should just initialize the block height to -1 (i.e. information isn't supported by the wrapper). An other option is simply removing the "height" attribute from Transaction and BlockchainInfoWrapper. That may make sense considering that I kept this information because I had it for free from bc.i but I never use it (even when displaying the results). Note that the same remark applies to the "time" attribute. Management of multisig scripts (and others fancy scripts) Good catch ! In order to solve this problem, you can replace
by
Ironically, I've got the same problem with bc.i but I can't use the same trick because bc.i doesn't return any address for raw multisigs. Anyway, this solution isn't going to work for scripts which don't have an address returned by the api and that may become a problem with segwit transactions. So far, my "best" idea is to replace the address by the raw scriptpubkey if no address is returned by the API. It may become ugly for some fancy scripts when results are displayed but that should work fine for computations. What do you think about it ? |
Nice, thank you.
Both of those make sense to me. I somewhat like the idea of leaving information we get for free (e.g. block height and time from BCI wrapper) in, in case you decide to make use of it later on in the project's lifespan, but we could make it clear which transaction fields are optional for wrappers to implement.
I like this idea for the rpc wrapper, but wonder what the ramifications will be down the line for having two wrappers that return different, non-null results. :/
I'm not too worried about that -- I think the BCI API will work similarly for segwit txs if segwit is ever adopted.
Yes, this makes sense to me as a fallback when no address is decodable. For outputs, we could use bci's |
Ok. Let's keep these information. I'm going to modify #6
It won't have any effect on the computations. Effects will be limited to the presentation of the results. In the case of a raw multisig, results based on data provided by bc.i api will be displayed with the scriptpubkey associated to the multisig, those based on the rpc api will be displayed with the multiple addresses.
Deal. Let's go for this fix. |
Code from this PR + modifications discussed here are included in PR #7 for merge with master. |
* Bitcoind rpc wrapper (code from PR #4 by K.Atlas) * updates readme
Adds wrapper for bitcoind's RPC interface.
This can be used instead of the remote API by passing the --rpc switch to ludwig.py and setting the appropriate environment variables.
There are some transactions that this cannot handle (e.g. pre-BIP30 transactions, genesis block coinbase) but that’s already broken for bci_wrapper so I didn’t try to fix things.
To ensure compatibility, I added a test class which compares wrapper output for 2 sample transactions and the capacity to add more easily.