jsonrpc: add a 'createspend' RPC command

Since the Spend transaction command requires some parameters, this
implements the parameter-getting logic on the JSONRPC side as well.

This allows us to implement an end-to-end functional test of the
transaction flow using an external way to broadcast it. From the input
coins creation, to the Spend transaction broadcast.
This commit is contained in:
Antoine Poinsot committed 2022-09-15 11:41:33 +02:00
1 parent 7468a7fcfb
commit 7d015bcf43
7 files changed
+237 -3

No files matched your search

+25
View File
@@ -84,3 +84,28 @@ This command does not take any parameter for now.
| `amount` | int | Value of the UTxO in satoshis |
| `outpoint` | string | Transaction id and output index of this coin |
| `block_height` | int or null | Blockheight the transaction was confirmed at, or `null` |
### `createspend`
Create a transaction spending one or more of our coins. All coins must exist and not be spent.
Will error if the given coins are not sufficient to cover the transaction cost at 90% (or more) of
the given feerate. If on the contrary the transaction is more than sufficiently funded, it will
create a change output when economically rationale to do so.
This command will refuse to create any output worth less than 5k sats.
#### Request
| Field | Type | Description |
| -------------- | ----------------- | ----------------------------------------------------------------- |
| `outpoints` | list of string | List of the coins to be spent, as `txid:vout`. |
| `destinations` | object | Map from Bitcoin address to value |
| `feerate` | integer | Target feerate for the transaction, in satoshis per virtual byte. |
#### Response
| Field | Type | Description |
| -------------- | --------- | ---------------------------------------------------- |
| `psbt` | string | PSBT of the spending transaction, encoded as base64. |