Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions token/services/interop/htlc/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (t *Transaction) Lock(wallet *token.OwnerWallet, sender view.Identity, typ
}

// Reclaim appends a reclaim (transfer) action to the token request of the transaction
func (t *Transaction) Reclaim(wallet *token.OwnerWallet, tok *token2.UnspentToken) error {
func (t *Transaction) Reclaim(wallet *token.OwnerWallet, tok *token2.UnspentToken, opts ...token.TransferOption) error {
q, err := token2.ToQuantity(tok.Quantity, t.TokenRequest.TokenService.PublicParametersManager().PublicParameters().Precision())
if err != nil {
return errors.Wrapf(err, "failed to convert quantity [%s]", tok.Quantity)
Expand Down Expand Up @@ -236,11 +236,17 @@ func (t *Transaction) Reclaim(wallet *token.OwnerWallet, tok *token2.UnspentToke
return err
}

return t.Transfer(wallet, tok.Type, []uint64{q.ToBigInt().Uint64()}, []view.Identity{script.Sender}, token.WithTokenIDs(tok.Id))
return t.Transfer(
wallet,
tok.Type,
[]uint64{q.ToBigInt().Uint64()},
[]view.Identity{script.Sender},
append(opts, token.WithTokenIDs(tok.Id))...,
)
}

// Claim appends a claim (transfer) action to the token request of the transaction
func (t *Transaction) Claim(wallet *token.OwnerWallet, tok *token2.UnspentToken, preImage []byte) error {
func (t *Transaction) Claim(wallet *token.OwnerWallet, tok *token2.UnspentToken, preImage []byte, opts ...token.TransferOption) error {
if len(preImage) == 0 {
return errors.New("preImage is nil")
}
Expand Down Expand Up @@ -309,8 +315,7 @@ func (t *Transaction) Claim(wallet *token.OwnerWallet, tok *token2.UnspentToken,
tok.Type,
[]uint64{q.ToBigInt().Uint64()},
[]view.Identity{script.Recipient},
token.WithTokenIDs(tok.Id),
token.WithTransferMetadata(ClaimKey(image), preImage),
append(opts, token.WithTokenIDs(tok.Id), token.WithTransferMetadata(ClaimKey(image), preImage))...,
)
}

Expand Down