-
Notifications
You must be signed in to change notification settings - Fork 78
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
Added GetTransactionMerkle to Electrum client #3578
Conversation
fd1e44a
to
150775e
Compare
615e6b5
to
2b1f14c
Compare
pkg/bitcoin/electrum/electrum.go
Outdated
getMerkleProofResult, err := requestWithRetry( | ||
c, | ||
func( | ||
ctx context.Context, | ||
client *electrum.Client, | ||
) (*electrum.GetMerkleProofResult, error) { | ||
return client.GetMerkleProof( | ||
ctx, | ||
transactionHash.String(), | ||
uint32(blockHeight), | ||
) | ||
}, | ||
) |
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.
We should pass the transaction hash in the ReversedByteOrder and be consistent with other functions implementations, see an example in the GetTransaction
function.
getMerkleProofResult, err := requestWithRetry( | |
c, | |
func( | |
ctx context.Context, | |
client *electrum.Client, | |
) (*electrum.GetMerkleProofResult, error) { | |
return client.GetMerkleProof( | |
ctx, | |
transactionHash.String(), | |
uint32(blockHeight), | |
) | |
}, | |
) | |
txID := transactionHash.Hex(bitcoin.ReversedByteOrder) | |
getMerkleProofResult, err := requestWithRetry( | |
c, | |
func( | |
ctx context.Context, | |
client *electrum.Client, | |
) (*electrum.GetMerkleProofResult, error) { | |
return client.GetMerkleProof( | |
ctx, | |
txID, | |
uint32(blockHeight), | |
) | |
}, | |
) |
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.
Done in c91b493.
@@ -295,6 +301,88 @@ func TestGetBlockHeader_Negative_Integration(t *testing.T) { | |||
} | |||
} | |||
|
|||
func TestGetTransactionMerkleProof_Integration(t *testing.T) { | |||
transactionHash, err := bitcoin.NewHashFromString( |
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.
Can we be consistent with other tests and define the transaction input and expected output in the test data package: "github.com/keep-network/keep-core/internal/testdata/bitcoin"?
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.
Moved the test data to keep-core/internal/testdata/bitcoin/transaction.go
in c647f19.
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.
Left some minor comments. Looks good to me, leaving it in @nkuba's hands as he requested changes.
Off to you @nkuba. |
This PR adds
GetTransactionMerkleProof
function to the Electrum client implementation.This function is needed to assemble SPV proof.