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: allow sha256 for HTLC #105

Merged
merged 2 commits into from
Jun 28, 2024

Conversation

doitian
Copy link
Member

@doitian doitian commented Jun 27, 2024

Allow use sha256 in TLC.

See contract PR nervosnetwork/fiber-scripts#6

  • Added a field hash_algorithm when adding TLC
  • Save the hash_algorithm in the internal TLC struct
  • Check hash against preimage using the saved hash_algorithm
  • Added hash_algorithm in the invoice as a new attribute

The sha256 TLC is covered in the e2e test case 3-nodes-transfer with extra args --env-var HASH_ALGORITHM=sha256

@doitian doitian force-pushed the feature/tlc-hash-algo branch from 4dc7a1f to f1970c8 Compare June 27, 2024 08:51
@doitian doitian changed the title WIP: TLC Hash Algorithm feat: allow sha256 for HTLC Jun 27, 2024
@doitian doitian force-pushed the feature/tlc-hash-algo branch 2 times, most recently from 0ac8a30 to 42b65d6 Compare June 27, 2024 09:00
@doitian doitian requested review from chenyukang and quake June 27, 2024 09:01
@doitian
Copy link
Member Author

doitian commented Jun 27, 2024

Need time to add tests to cover SHA256 HTLC, but the code is ready for review.

@doitian doitian force-pushed the feature/tlc-hash-algo branch from 42b65d6 to 213e998 Compare June 27, 2024 09:04
@doitian doitian marked this pull request as ready for review June 27, 2024 09:09
@doitian doitian force-pushed the feature/tlc-hash-algo branch 8 times, most recently from dcdd6a5 to 871095b Compare June 28, 2024 01:47
doitian added 2 commits June 28, 2024 10:45
Allow choosing the hash algorithm when adding the HTLC output.

Related PR: nervosnetwork/fiber-scripts#6

- Added a field `hash_algorithm` when adding TLC
- Save the `hash_algorithm` in the internal TLC struct
- Check hash against preimage using the saved `hash_algorithm`
- Added `hash_algorithm` in the invoice as a new attribute
@doitian doitian force-pushed the feature/tlc-hash-algo branch from 871095b to b92895d Compare June 28, 2024 02:45
Copy link
Collaborator

@contrun contrun left a comment

Choose a reason for hiding this comment

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

Generally LGTM. We may also need to update the binaries in the folder tests/deploy/contracts so that we can use the latest contracts. There are some tests in this repo that directly run these contract to see if the generated transactions are valid.

src/ckb/hash_algorithm.rs Show resolved Hide resolved
@doitian doitian merged commit f84cb3d into nervosnetwork:main Jun 28, 2024
11 checks passed
@doitian doitian mentioned this pull request Jul 1, 2024
3 tasks
@doitian doitian deleted the feature/tlc-hash-algo branch July 18, 2024 08:39
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.

3 participants