feat(tokens): add HTLC lock, claim, and reclaim service layer - #29
Open
atharrva01 wants to merge 1 commit into
Open
atharrva01 wants to merge 1 commit into
atharrva01 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-sideLockAcceptresponder),Claim, andReclaim, mirroringowner/service/fsc.go's existingTransferView/RedeemViewshape. No REST surface yet — that's next (week 4), once this is proven.Ported from the pre-rename
fabric-token-sdkintegration/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, andOutputsall gained a leadingctx.Contextparam since the reference was written.ttx.WithAuditor— no auditor identity exists anywhere in this app's config, and the liveTransfer/Redeemviews already pass zeroTxOptions; HTLC follows the same pattern.htlc.NewTransaction(named signer) instead of the reference'sNewAnonymousTransaction: 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.ExchangeRecipientIdentities/RespondExchangeRecipientIdentitiesrather thanfsc.go'sgetRemoteIdentity/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. TheBindstep fromgetRemoteIdentityis still needed first.TMSIDselector (via the existingcommon/views.ServiceOpts/TxOptshelpers), so a second TMS is additive rather than a breaking change.Test plan
go build/go vetclean on both the default andfabricxbuild tags