-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add gettxspendingprevout
for btcd
and fix version check
#2125
Add gettxspendingprevout
for btcd
and fix version check
#2125
Conversation
Pull Request Test Coverage Report for Build 8077551462Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🌂
rpcclient/infrastructure.go
Outdated
@@ -1648,6 +1658,9 @@ func parseBitcoindVersion(version string) BackendVersion { | |||
case version < bitcoind22Str: | |||
return BitcoindPre22 | |||
|
|||
case version < bitcoind24Str: | |||
return BitcoindPre24 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, we need to start to check this in btcwallet
? FWIW, didn't see it in the latest PR of yours in that repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'll need to check this in lnd
at the callsite. If we check it in btcwallet
, then it's another error to be returned to the caller. On the other hand, I think the rpcclient
package should be put in btcwallet
instead to keep btcd
"pure" - came up with a draft PR for this when I was dealing with updating errors returned from TestMempoolAccept
, will put more details there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the rpcclient package should be put in btcwallet instead to keep btcd "pure" - came up with a draft PR for this when I was dealing with updating errors returned from TestMempoolAccept, will put more details there.
Don't think I agree with this, rpcclient
as is does generic JSON-RPC for conformant Bitcoin nodes. We even use the client to test directly against (in itests) the server-side implementation of the various RPC calls.
I don't see why the check can't just be in the wallet though. We already have that check for bitcoind
when we wan to use the newer set of RPC calls.
This commit adds the RPC method `gettxspendingprevout` for btcd.
We need this for `gettxspendingprevout`.
This commit adds a new interface, `BackendVersion`, to support checking versions for multiple both btcd and bitcoind. Once neutrino version is also pinned here, it should also be checked.
2cfa802
to
4cf49bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎒
cc: @Crypt-iQ for review |
cc: @guggero |
Nice pr @yyforyongyu I like the progression. question/suggestion: Do you think we should separate the implementations of the Backend version interface into separate files? like bitcoin.go and btcd.go in the same folder. In the future if we want to track more backends we just create a new file and that way it is easier to follow? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, LGTM 🎉
@@ -3906,6 +3907,49 @@ func handleTestMempoolAccept(s *rpcServer, cmd interface{}, | |||
return results, nil | |||
} | |||
|
|||
// handleGetTxSpendingPrevOut implements the gettxspendingprevout command. | |||
func handleGetTxSpendingPrevOut(s *rpcServer, cmd interface{}, | |||
closeChan <-chan struct{}) (interface{}, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: since closeChan
is unused, should we just use _
as the argument name?
|
||
// Call the method handler and assert the error is returned. | ||
closeChan := make(chan struct{}) | ||
results, err := handleGetTxSpendingPrevOut(s, cmd, closeChan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could just pass in nil
since closeChan
is not used anyway.
type BackendVersion uint8 | ||
// BackendVersion defines an interface to handle the version of the backend | ||
// used by the client. | ||
type BackendVersion interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 🤩
c.backendVersion = &version | ||
return *c.backendVersion, nil | ||
version := parseBtcdVersion(info.Version) | ||
c.backendVersion = version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: why not c.backendVersion = parseBtcdVersion(info.Version)
directly?
@Chinwendu20, I think if we did that, we'd want to add a version prefix/suffix to the file names, so it's clear that this is code for parsing the versions, rather than a |
This PR adds the RPC
gettxspendingprevout
forbtcd
so we can do mempool lookups. This RPC is also ported to therpcclient
to replace the raw request made on the btcwallet side.In addition, we now start to track
btcd
versions inrpcclient
to make sure RPC updates are handled properly.