Skip to content

Commit

Permalink
Merge #927: commands: include missing amount in spend response
Browse files Browse the repository at this point in the history
1339898 commands: include missing amount in response (jp1ac4)

Pull request description:

  This PR follows a discussion around #873 (comment).

  The GUI uses the `InsufficientFunds` error to get the missing amount when the user is creating a new spend, but it is not straightforward to extract this information in a general way from the RPC error (see #822 (comment)) and instead the spend module's `create_spend` is currently used (see #863).

  With this PR, the missing amount will be included in the `createspend` response rather than as an error.

  These changes are based on suggestions from @darosior and @edouardparis.

  In a follow-up PR, the GUI should revert to using the `createspend` command to calculate the amount left to select.

ACKs for top commit:
  darosior:
    re-ACK 1339898

Tree-SHA512: bf702d6b355339e96e719c1d95824e7941ac4fbaece4ec4cccd00b56ea4683ce7fb0cefc43faa5731b57e7935ef99da3a2c73b84aaeb9fa5f67703c799be2196
  • Loading branch information
darosior committed Jan 23, 2024
2 parents e671e50 + 1339898 commit 79141e2
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 @@ -180,11 +180,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 @@ -295,9 +302,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 79141e2

Please sign in to comment.