Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: BumpWalletTransaction rpc #388

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
29 changes: 29 additions & 0 deletions cmd/boltzcli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,12 @@ var walletCommands = &cli.Command{
Action: requireNArgs(1, listTransactions),
Flags: []cli.Flag{jsonFlag, &cli.BoolFlag{Name: "exclude-swap-related", Usage: "Exclude swap related transactions"}},
},
{
Name: "bumpfee",
ArgsUsage: "name txid fee-rate",
Usage: "Bump the fee of a transaction",
Action: requireNArgs(3, bumpFee),
},
{
Name: "subaccounts",
Usage: "Show the subaccounts of a wallet",
Expand Down Expand Up @@ -2036,6 +2042,29 @@ func listTransactions(ctx *cli.Context) error {
return nil
}

func bumpFee(ctx *cli.Context) error {
client := getClient(ctx)
walletId, err := getWalletId(ctx, ctx.Args().First())
if err != nil {
return fmt.Errorf("wallet not found: %s", err)
}
txid := ctx.Args().Get(1)
feeRate, err := strconv.ParseFloat(ctx.Args().Get(2), 64)
if err != nil {
return fmt.Errorf("invalid fee rate: %s", err)
}
response, err := client.BumpWalletTransaction(&boltzrpc.BumpWalletTransactionRequest{
Id: *walletId,
TxId: txid,
SatPerVbyte: feeRate,
})
if err != nil {
return err
}
printJson(response)
return nil
}

var formatMacaroonCommand = &cli.Command{
Name: "formatmacaroon",
Category: "Debug",
Expand Down
36 changes: 36 additions & 0 deletions docs/grpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ Returns recent transactions from a wallet.
| ------- | -------- |
| [`ListWalletTransactionsRequest`](#listwallettransactionsrequest) | [`ListWalletTransactionsResponse`](#listwallettransactionsresponse) |

#### BumpWalletTransaction

Increase the fee of a wallet transaction using RBF.

| Request | Response |
| ------- | -------- |
| [`BumpWalletTransactionRequest`](#bumpwallettransactionrequest) | [`BumpWalletTransactionResponse`](#bumpwallettransactionresponse) |

#### GetWalletCredentials

Returns the credentials of a wallet. The password will be required if the wallet is encrypted.
Expand Down Expand Up @@ -395,6 +403,34 @@ Bakes a new macaroon with the specified permissions. The macaroon can also be re



#### BumpWalletTransactionRequest




| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `id` | [`uint64`](#uint64) | | id of the wallet which the transaction belongs to |
| `sat_per_vbyte` | [`double`](#double) | | fee rate for the new transaction |
| `tx_id` | [`string`](#string) | | id of the transaction to bump |





#### BumpWalletTransactionResponse




| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `tx_id` | [`string`](#string) | | |





#### ChainSwapData


Expand Down
4 changes: 4 additions & 0 deletions internal/cln/cln.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ func (c *Cln) GetTransactions(limit, offset uint64) ([]*onchain.WalletTransactio
return nil, errors.New("not implemented for cln")
}

func (c *Cln) BumpTransactionFee(txId string, feeRate float64) (string, error) {
return "", errors.New("not implemented for cln")
}

func (c *Cln) SanityCheck() (string, error) {
info, err := c.Client.Getinfo(context.Background(), &protos.GetinfoRequest{})
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions internal/lnd/lnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ func (lnd *LND) GetTransactions(limit, offset uint64) ([]*onchain.WalletTransact
return nil, errors.New("not implemented for lnd")
}

func (lnd *LND) BumpTransactionFee(txId string, feeRate float64) (string, error) {
return "", errors.New("not implemented for lnd")
}

func (lnd *LND) CreateInvoice(value uint64, preimage []byte, expiry int64, memo string) (*lightning.AddInvoiceResponse, error) {
request := &lnrpc.Invoice{
Memo: memo,
Expand Down
4 changes: 4 additions & 0 deletions internal/macaroons/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ var (
Entity: "wallet",
Action: "read",
}},
"/boltzrpc.Boltz/BumpWalletTransaction": {{
Entity: "wallet",
Action: "write",
}},
"/boltzrpc.Boltz/GetWallet": {{
Entity: "wallet",
Action: "read",
Expand Down
57 changes: 57 additions & 0 deletions internal/mocks/lightning/LightningNode_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions internal/mocks/onchain/Wallet_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/onchain/onchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ type Wallet interface {
GetWalletInfo() WalletInfo
Disconnect() error
GetTransactions(limit, offset uint64) ([]*WalletTransaction, error)
BumpTransactionFee(txId string, satPerVbyte float64) (string, error)
}

type ElectrumOptions struct {
Expand Down
Loading
Loading