Skip to content

feat(tokens): add HTLC lock, claim, and reclaim service layer - #29

Open
atharrva01 wants to merge 1 commit into
hyperledger:mainfrom
atharrva01:feature/issue-66-week3-htlc-service-layer
Open

atharrva01 wants to merge 1 commit into
hyperledger:mainfrom
atharrva01:feature/issue-66-week3-htlc-service-layer

Conversation

@atharrva01

Copy link
Copy Markdown
Contributor

Summary

Week 3 of issue #66's deliverable 3 (HTLC locks). Adds the FSC view layer driving Panurus's existing HTLC protocol (token/services/interop/htlc): Lock (+ the recipient-side LockAccept responder), Claim, and Reclaim, mirroring owner/service/fsc.go's existing TransferView/RedeemView shape. No REST surface yet — that's next (week 4), once this is proven.

Ported from the pre-rename fabric-token-sdk integration/ package's own reference views (removed from the published module at v0.13.0; per mentor guidance, that module is for Panurus's own internal parts and isn't meant to be imported, so the logic is carried locally instead), adjusted for v0.18.0's current API:

  • Claim, Reclaim, and Outputs all gained a leading ctx.Context param since the reference was written.
  • Dropped ttx.WithAuditor — no auditor identity exists anywhere in this app's config, and the live Transfer/Redeem views already pass zero TxOptions; HTLC follows the same pattern.
  • Uses htlc.NewTransaction (named signer) instead of the reference's NewAnonymousTransaction: the latter needs an "idemix" FSC-native identity this app's fabric3 config has never set up (nothing else here uses an anonymous transaction), so it fails "identity [idemix] not found" instead of a real bug. Named signing avoids that entirely and matches every other flow in this app.
  • Recipient-identity exchange uses htlc's own ExchangeRecipientIdentities/RespondExchangeRecipientIdentities rather than fsc.go's getRemoteIdentity/RequestRecipientIdentity: the lock script asserts a specific (sender, recipient) identity pair on both sides, and only the htlc-native exchange guarantees both parties agree on the same pair. The Bind step from getRemoteIdentity is still needed first.
  • Every new Options struct carries a TMSID selector (via the existing common/views.ServiceOpts/TxOpts helpers), so a second TMS is additive rather than a breaking change.

Test plan

  • go build/go vet clean on both the default and fabricx build tags
  • Verified against a live fabric3 network via a temporary debug HTTP handler (removed before this commit): lock→claim moved 10 TOK from alice to dan correctly; a second lock with a 10s deadline, reclaimed after expiry, returned the tokens to alice and left the original pre-image unclaimable

Adds the FSC view layer driving Panurus's existing HTLC protocol
(token/services/interop/htlc): Lock (+ the recipient-side LockAccept
responder), Claim, and Reclaim, mirroring owner/service/fsc.go's
existing TransferView/RedeemView shape. No REST surface yet -- that's
next, once this is proven.

Ported from the pre-rename fabric-token-sdk integration/ package's own
reference views (removed from the published module at v0.13.0; per
mentor guidance this cycle, that module is for Panurus's own internal
parts and isn't meant to be imported, so the logic is carried locally
instead), adjusted for v0.18.0's current API:

- Claim, Reclaim, and Outputs all gained a leading ctx.Context param
  since the reference was written.
- Dropped ttx.WithAuditor -- no auditor identity exists anywhere in
  this app's config, and the live Transfer/Redeem views already pass
  zero TxOptions; HTLC follows the same pattern.
- Uses htlc.NewTransaction (named signer) instead of the reference's
  NewAnonymousTransaction: the latter needs an "idemix" FSC-native
  identity this app's fabric3 config has never set up (nothing else
  here uses an anonymous transaction), so it fails "identity [idemix]
  not found" instead of a real bug. Named signing avoids that entirely
  and matches every other flow in this app.
- Recipient-identity exchange uses htlc's own ExchangeRecipientIdentities/
  RespondExchangeRecipientIdentities rather than fsc.go's
  getRemoteIdentity/RequestRecipientIdentity: the lock script asserts a
  specific (sender, recipient) identity pair on both sides, and only
  the htlc-native exchange guarantees both parties agree on the same
  pair. The Bind step from getRemoteIdentity is still needed first.
- Every new Options struct carries a TMSID selector (via the existing
  common/views.ServiceOpts/TxOpts helpers), so a second TMS is
  additive rather than a breaking change.

Verified against a live fabric3 network via a temporary debug HTTP
handler (removed before this commit): lock->claim moved 10 TOK from
alice to dan correctly; a second lock with a 10s deadline, reclaimed
after expiry, returned the tokens to alice and left the original
pre-image unclaimable.

Signed-off-by: atharrva01 <atharvaborade568@gmail.com>
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.

1 participant