Skip to content

Commit

Permalink
lwkwallet: implement SetLabel method
Browse files Browse the repository at this point in the history
implement SetLabel method to call walletSetTxMemo
for setting transaction memos.
  • Loading branch information
YusukeShimizu committed Jun 30, 2024
1 parent dfb4967 commit 38524dd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
17 changes: 17 additions & 0 deletions lwk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,20 @@ func (l *lwkclient) version(ctx context.Context) (*versionResponse, error) {
}
return &resp, nil
}

type WalletSetTxMemoRequest struct {
Memo string `json:"memo"`
WalletName string `json:"name"`
Txid string `json:"txid"`
}

func (r *WalletSetTxMemoRequest) Name() string {
return "wallet_set_tx_memo"
}

type WalletSetTxMemoResponse struct {
}

func (l *lwkclient) walletSetTxMemo(ctx context.Context, req *WalletSetTxMemoRequest) error {
return l.request(ctx, req, &WalletSetTxMemoResponse{})
}
9 changes: 7 additions & 2 deletions lwk/lwkwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,13 @@ func (r *LWKRpcWallet) GetFee(txSizeBytes int64) (Satoshi, error) {
}

func (r *LWKRpcWallet) SetLabel(txID, address, label string) error {
// TODO: call set label
return nil
ctx, cancel := context.WithTimeout(context.Background(), defaultContextTimeout)
defer cancel()
return r.lwkClient.walletSetTxMemo(ctx, &WalletSetTxMemoRequest{
WalletName: r.c.GetWalletName(),
Txid: txID,
Memo: label,
})
}

func (r *LWKRpcWallet) Ping() (bool, error) {
Expand Down

0 comments on commit 38524dd

Please sign in to comment.