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

feat: support Bitcoin P2TR, P2WSH, P2SH, P2PKH address types #1982

Merged
merged 29 commits into from
Apr 4, 2024

Conversation

ws4charlie
Copy link
Contributor

Description

  1. Currently we only support sending to P2WPKH address. Need to support P2TR/P2PKH/P2SH/P2WSH.
  2. Currently we only support receiving BTC from P2WPKH address. Need to support P2TR/P2PKH/P2SH/P2WSH.

WIP:

  • backport AddressTaproot type that fulfills the btcutil.Address interface
  • add P2TR output
  • add P2PKH output
  • add P2SH output
  • add P2WSH output
  • read P2TR sender
  • read P2SH sender
  • read P2PKH sender
  • read P2WSH sender

Closes:
1626
1627
1773

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Include instructions and any relevant details so others can reproduce.

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Checklist:

  • I have added unit tests that prove my fix feature works

@github-actions github-actions bot added ci Changes to CI pipeline or github actions breaking:cli labels Apr 3, 2024
@ws4charlie ws4charlie marked this pull request as draft April 3, 2024 16:17
@github-actions github-actions bot removed the ci Changes to CI pipeline or github actions label Apr 3, 2024
Copy link

github-actions bot commented Apr 3, 2024

!!!WARNING!!!
nosec detected in the following files: zetaclient/bitcoin/fee.go, zetaclient/bitcoin/fee_test.go, e2e/e2etests/e2etests.go, zetaclient/bitcoin/bitcoin_client.go, zetaclient/bitcoin/bitcoin_client_test.go, zetaclient/bitcoin/bitcoin_signer.go, zetaclient/bitcoin/bitcoin_signer_test.go, zetaclient/bitcoin/inbound_tracker.go, zetaclient/bitcoin/utils.go

Be very careful about using #nosec in code. It can be a quick way to suppress security warnings and move forward with development, it should be employed with caution. Suppressing warnings with #nosec can hide potentially serious vulnerabilities. Only use #nosec when you're absolutely certain that the security issue is either a false positive or has been mitigated in another way.

Only suppress a single rule (or a specific set of rules) within a section of code, while continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within the #nosec annotation, e.g: /* #nosec G401 */ or //#nosec G201 G202 G203
Broad #nosec annotations should be avoided, as they can hide other vulnerabilities. The CI will block you from merging this PR until you remove #nosec annotations that do not target specific rules.

Pay extra attention to the way #nosec is being used in the files listed above.

@github-actions github-actions bot added the nosec label Apr 3, 2024
Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 80.58036% with 87 lines in your changes are missing coverage. Please review.

Project coverage is 63.90%. Comparing base (ae29968) to head (b15de98).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1982      +/-   ##
===========================================
+ Coverage    62.96%   63.90%   +0.93%     
===========================================
  Files          233      236       +3     
  Lines        13407    13631     +224     
===========================================
+ Hits          8442     8711     +269     
+ Misses        4566     4504      -62     
- Partials       399      416      +17     
Files Coverage Δ
x/crosschain/keeper/evm_hooks.go 82.60% <100.00%> (-0.10%) ⬇️
zetaclient/bitcoin/utils.go 26.92% <ø> (-47.25%) ⬇️
zetaclient/bitcoin/inbound_tracker.go 0.00% <0.00%> (ø)
x/crosschain/types/validate.go 81.81% <0.00%> (-6.42%) ⬇️
pkg/chains/address.go 93.47% <78.57%> (-6.53%) ⬇️
zetaclient/bitcoin/bitcoin_signer.go 21.81% <79.48%> (+14.19%) ⬆️
zetaclient/bitcoin/tx_script.go 93.10% <93.10%> (ø)
zetaclient/bitcoin/fee.go 89.89% <89.89%> (ø)
zetaclient/bitcoin/bitcoin_client.go 23.73% <79.06%> (+7.29%) ⬆️
pkg/chains/address_taproot.go 58.42% <58.42%> (ø)

@ws4charlie ws4charlie marked this pull request as ready for review April 3, 2024 18:51
@ws4charlie ws4charlie merged commit f845afc into develop Apr 4, 2024
21 checks passed
@ws4charlie ws4charlie deleted the feat-support-taproot branch April 4, 2024 04:46
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.

5 participants