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

Use correct type for parameters in ExtendedBitcoinClient #1248

Merged
merged 2 commits into from
Apr 7, 2020

Conversation

araspitzu
Copy link
Contributor

Replace the usage of String with the more precise ByteVector32

@pm47
Copy link
Member

pm47 commented Dec 11, 2019

You missed those ones:

def isTransactionOutputSpendable(txId: String, outputIndex: Int, includeMempool: Boolean)(implicit ec: ExecutionContext): Future[Boolean] = rpcClient.invoke("gettxout", txId, outputIndex, includeMempool) collect { case j => j != JNull }

Also maybe take the opportunity to homogeneize between txId and txid? I think the latter is what bitcoin-lib uses.

@araspitzu
Copy link
Contributor Author

araspitzu commented Dec 11, 2019

Didn't miss them but they're out of scope for the PR. In fact i think we shouldn't just fix them in BitcoinCoreWallet but we should use ExtendedBitcoinClient , if you notice isTransactionOutputSpendable and it's implementation are duplicated between wallet and client. What do you think of using the ExtendedBitcoinClient inside BitcoinCoreWallet?

@pm47
Copy link
Member

pm47 commented Dec 11, 2019

I think the problem is that ExtendedBitcoinClient is bulky and I didn't want to make the small BitcoinCoreWallet depend on it.

How about making ExtendedBitcoinClient use the pimp pattern to extend BitcoinJsonRPCClient, the same way we made ExtendedResultSet extend ResultSet in order to do rs.getByteVector with the database? We could then move all the bitcoind-related functions of BitcoinCoreWallet to ExtendedBitcoinClient and that would address your concern.

@pm47
Copy link
Member

pm47 commented Dec 11, 2019

Wait I'm changing my mind. I don't think pimp pattern is a good idea because we are not extending BitcoinJsonRPCClient with other functions similar to the ones it already has, we are adding a set of functions that are much more higher level than what it currently does.

@pm47
Copy link
Member

pm47 commented Dec 11, 2019

What do you think of using the ExtendedBitcoinClient inside BitcoinCoreWallet?

Yes let's do this. I think maybe as a next step we could consider making ExtendedBitcoinClient an object.

@araspitzu
Copy link
Contributor Author

Wait I'm changing my mind. I don't think pimp pattern is a good idea because we are not extending BitcoinJsonRPCClient with other functions similar to the ones it already has, we are adding a set of functions that are much more higher level than what it currently does.

👍 I was also hesitant with making ExtendedBitcoinClient use the pimp pattern to extend BitcoinJsonRPCClient, it feels more natural that one uses the other but without extending it. Maybe we should take some time to clean up ExtendedBitcoinClient to be able to use it from BitcoinCoreWallet, i would like to remove the code duplication that we currently have. I'm in favour of doing the necessary cleansing here in this PR.

@araspitzu araspitzu force-pushed the bitcoin_client_typed_params branch from f633157 to c1b06c8 Compare December 11, 2019 15:15
@codecov-io
Copy link

codecov-io commented Dec 11, 2019

Codecov Report

Merging #1248 into master will increase coverage by 0.06%.
The diff coverage is 85.71%.

@@            Coverage Diff             @@
##           master    #1248      +/-   ##
==========================================
+ Coverage   86.35%   86.41%   +0.06%     
==========================================
  Files         119      119              
  Lines        9253     9251       -2     
  Branches      398      375      -23     
==========================================
+ Hits         7990     7994       +4     
+ Misses       1263     1257       -6     
Impacted Files Coverage Δ
...eclair/blockchain/bitcoind/BitcoinCoreWallet.scala 88.88% <83.33%> (-0.40%) ⬇️
...lockchain/bitcoind/rpc/ExtendedBitcoinClient.scala 92.30% <83.33%> (ø)
.../acinq/eclair/blockchain/bitcoind/ZmqWatcher.scala 96.26% <87.50%> (ø)
...chain/bitcoind/rpc/BasicBitcoinJsonRPCClient.scala 100.00% <100.00%> (ø)
...q/eclair/blockchain/electrum/ElectrumWatcher.scala 55.20% <0.00%> (+1.60%) ⬆️
...clair/blockchain/electrum/ElectrumClientPool.scala 82.79% <0.00%> (+4.30%) ⬆️

@araspitzu
Copy link
Contributor Author

araspitzu commented Dec 12, 2019

Latest commit 3410f46 is a small improvement in the BitcoinCoreWallet to remove duplicate code. I didn't migrate the ExtendedBitcoinClient to be an object because it makes it harder to test and breaks composability.

@t-bast
Copy link
Member

t-bast commented Mar 27, 2020

Is there something blocking this PR (apart from a rebase)?
It looks like a refactoring we may want to include before the next release.

@araspitzu araspitzu force-pushed the bitcoin_client_typed_params branch from 3410f46 to 5eaee70 Compare March 27, 2020 10:09
@araspitzu
Copy link
Contributor Author

Rebased on master

@araspitzu
Copy link
Contributor Author

For reviewers: the commit history of this PR is not great let me know if you want a squash/rebase.

@t-bast
Copy link
Member

t-bast commented Mar 27, 2020

let me know if you want a squash/rebase

Yes let's start fresh with a rebase (maybe once cltv-tie-breaker is merged since there will be conflicts).

@araspitzu araspitzu force-pushed the bitcoin_client_typed_params branch from 54f84d6 to ecacb97 Compare March 30, 2020 10:19
@araspitzu
Copy link
Contributor Author

Rebased on master and squash/merged the commit history of this PR.

@araspitzu araspitzu force-pushed the bitcoin_client_typed_params branch from 8d6cc4e to 380e4b3 Compare March 30, 2020 16:22
@araspitzu
Copy link
Contributor Author

In 380e4b3 i addressed some of your comments and i cleaned up BitcoinCoreWallet of some unused functions that were just an alias for ExtendedBitcoinClient.

Copy link
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's not dive into the rabbit hole of refactoring all our bitcoin-cli calls now :)
I'm not ack-ing now, I think this should be merged right after we cut the release for eclair 0.3.4.

@araspitzu araspitzu merged commit 7866be1 into master Apr 7, 2020
@araspitzu araspitzu deleted the bitcoin_client_typed_params branch April 8, 2020 12:23
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

Successfully merging this pull request may close these issues.

4 participants