Skip to content

Commit 34505c0

Browse files
committed
allow custom transfer options for claim and reclaim and merge them with the htlc opts
Signed-off-by: Arne Rutjes <arne123@gmail.com>
1 parent 5150e41 commit 34505c0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

token/services/interop/htlc/transaction.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func (t *Transaction) Lock(wallet *token.OwnerWallet, sender view.Identity, typ
195195
}
196196

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

239-
return t.Transfer(wallet, tok.Type, []uint64{q.ToBigInt().Uint64()}, []view.Identity{script.Sender}, token.WithTokenIDs(tok.Id))
239+
return t.Transfer(
240+
wallet,
241+
tok.Type,
242+
[]uint64{q.ToBigInt().Uint64()},
243+
[]view.Identity{script.Sender},
244+
append(opts, token.WithTokenIDs(tok.Id))...,
245+
)
240246
}
241247

242248
// Claim appends a claim (transfer) action to the token request of the transaction
243-
func (t *Transaction) Claim(wallet *token.OwnerWallet, tok *token2.UnspentToken, preImage []byte) error {
249+
func (t *Transaction) Claim(wallet *token.OwnerWallet, tok *token2.UnspentToken, preImage []byte, opts ...token.TransferOption) error {
244250
if len(preImage) == 0 {
245251
return errors.New("preImage is nil")
246252
}
@@ -309,8 +315,7 @@ func (t *Transaction) Claim(wallet *token.OwnerWallet, tok *token2.UnspentToken,
309315
tok.Type,
310316
[]uint64{q.ToBigInt().Uint64()},
311317
[]view.Identity{script.Recipient},
312-
token.WithTokenIDs(tok.Id),
313-
token.WithTransferMetadata(ClaimKey(image), preImage),
318+
append(opts, token.WithTokenIDs(tok.Id), token.WithTransferMetadata(ClaimKey(image), preImage))...,
314319
)
315320
}
316321

0 commit comments

Comments
 (0)