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

Added GetTransactionMerkle to Electrum client #3578

Merged
merged 13 commits into from
May 23, 2023
Merged

Added GetTransactionMerkle to Electrum client #3578

merged 13 commits into from
May 23, 2023

Conversation

tomaszslabon
Copy link
Contributor

@tomaszslabon tomaszslabon commented May 19, 2023

This PR adds GetTransactionMerkleProof function to the Electrum client implementation.
This function is needed to assemble SPV proof.

@tomaszslabon tomaszslabon requested review from pdyraga, lukasz-zimnoch and nkuba and removed request for pdyraga May 19, 2023 08:55
Comment on lines 311 to 323
getMerkleProofResult, err := requestWithRetry(
c,
func(
ctx context.Context,
client *electrum.Client,
) (*electrum.GetMerkleProofResult, error) {
return client.GetMerkleProof(
ctx,
transactionHash.String(),
uint32(blockHeight),
)
},
)
Copy link
Member

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.

Suggested change
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),
)
},
)

Copy link
Contributor Author

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(
Copy link
Member

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"?

Copy link
Contributor Author

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.

Copy link
Member

@pdyraga pdyraga left a 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.

@pdyraga
Copy link
Member

pdyraga commented May 23, 2023

Off to you @nkuba.

@nkuba nkuba merged commit fe9cea4 into main May 23, 2023
@nkuba nkuba deleted the modify-electrum branch May 23, 2023 19:14
@pdyraga pdyraga added this to the v2.0.0-m3 milestone May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants