Skip to content

Commit

Permalink
commands: include missing amount in response
Browse files Browse the repository at this point in the history
The GUI uses the InsufficientFunds error to get the missing
amount when the user is creating a new spend.

It is not straightforward to extract this information in a
general way from the RPC error. Instead, this missing amount
will be included in the command response.

These changes are based on suggestions from darosior
and edouardparis.
  • Loading branch information
jp1ac4 committed Jan 23, 2024
1 parent 7ca6cc8 commit 1339898
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 124 deletions.
11 changes: 8 additions & 3 deletions doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,18 @@ This command will refuse to create any output worth less than 5k sats.

#### Response

If the spend is created successfully, the following response will be received:

| Field | Type | Description |
| -------------- | ----------------- | ---------------------------------------------------- |
| `psbt` | string | PSBT of the spending transaction, encoded as base64. |
| `warnings` | list of string | Warnings, if any, generated during spend creation. |

If there are insufficient funds to create the required spend, then the following response will be received:

| Field | Type | Description |
| -------------- | ----------------- | ---------------------------------------------------- |
| `missing` | integer | Additional sats required to create the spend. |

### `updatespend`

Expand Down Expand Up @@ -294,9 +301,7 @@ allowed in order to replace this transaction using RBF (see https://github.com/b

#### Response

| Field | Type | Description |
| -------------- | --------- | ---------------------------------------------------- |
| `psbt` | string | PSBT of the spending transaction, encoded as base64. |
The response is the same as for [`createspend`](#createspend).

### `startrescan`

Expand Down
Loading

0 comments on commit 1339898

Please sign in to comment.