txprepare, withdraw: return the PSBT as well as raw tx.

In particular, txprepare gives us a nice way to get a valid PSBT for
testing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `txprepare` and `withdraw` now return a `psbt` field.
This commit is contained in:
Rusty Russell 2021-03-15 14:57:59 +10:30
parent dc44737fb8
commit 43a553f5ac
5 changed files with 14 additions and 12 deletions

View File

@ -57,13 +57,13 @@ is provided by \fBtxsend\fR\.
.SH RETURN VALUE
On success, an object with attributes \fIunsigned_tx\fR and \fItxid\fR will be
On success, an object with attributes \fIunsigned_tx\fR, \fIpsbt\fR and \fItxid\fR will be
returned\. You need to hand \fItxid\fR to \fBtxsend\fR or \fBtxdiscard\fR, as the
inputs of this transaction are reserved until then, or until the daemon
restarts\.
\fIunsigned_tx\fR represents the raw bitcoin transaction (not yet signed)
\fIunsigned_tx\fR and \fIpsbt\fR represent the raw bitcoin transaction (not yet signed)
and \fItxid\fR represent the bitcoin transaction id\.
@ -95,4 +95,4 @@ Rusty Russell \fI<rusty@rustcorp.com.au\fR> is mainly responsible\.
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:b3ff9c69ce535b79307ce103f8f9e5d64115a8ed388c471af37a637b9e970ae7
\" SHA256STAMP:ebbe475ef5a3df39e772789cf3df94757662408758f0f6bb300b120d2abefebc

View File

@ -52,12 +52,12 @@ is provided by **txsend**.
RETURN VALUE
------------
On success, an object with attributes *unsigned\_tx* and *txid* will be
On success, an object with attributes *unsigned\_tx*, *psbt* and *txid* will be
returned. You need to hand *txid* to **txsend** or **txdiscard**, as the
inputs of this transaction are reserved until then, or until the daemon
restarts.
*unsigned\_tx* represents the raw bitcoin transaction (not yet signed)
*unsigned\_tx* and *psbt* represent the raw bitcoin transaction (not yet signed)
and *txid* represent the bitcoin transaction id.
On failure, an error is reported and the transaction is not created.

View File

@ -43,11 +43,11 @@ of "txid:vout"\. These must be drawn from the node's available UTXO set\.
.SH RETURN VALUE
On success, an object with attributes \fItx\fR and \fItxid\fR will be returned\.
On success, an object with attributes \fItx\fR, \fItxid\fR and \fIpsbt\fR will be returned\.
\fItx\fR represents the raw bitcoin, fully signed, transaction and \fItxid\fR
represent the bitcoin transaction id\.
\fItx\fR and \fIpsbt\fR represent the fully signed bitcoin transaction and \fItxid\fR
represents the bitcoin transaction id\.
On failure, an error is reported and the withdrawal transaction is not
@ -79,4 +79,4 @@ Felix \fI<fixone@gmail.com\fR> is mainly responsible\.
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:e32366bb53ffbf212d8629aba20361258f2d5534de6c2b625153c457e888beb6
\" SHA256STAMP:0afffd7ffd7b22415e67816cc43d3be6fdde8deda863a0981f383cdc7ba48513

View File

@ -40,10 +40,10 @@ of "txid:vout". These must be drawn from the node's available UTXO set.
RETURN VALUE
------------
On success, an object with attributes *tx* and *txid* will be returned.
On success, an object with attributes *tx*, *txid* and *psbt* will be returned.
*tx* represents the raw bitcoin, fully signed, transaction and *txid*
represent the bitcoin transaction id.
*tx* and *psbt* represent the fully signed bitcoin transaction and *txid*
represents the bitcoin transaction id.
On failure, an error is reported and the withdrawal transaction is not
created.

View File

@ -138,6 +138,7 @@ static struct command_result *sendpsbt_done(struct command *cmd,
out = jsonrpc_stream_success(cmd);
json_add_hex_talarr(out, "tx", linearize_wtx(tmpctx, utx->tx));
json_add_txid(out, "txid", &utx->txid);
json_add_psbt(out, "psbt", utx->psbt);
return command_finished(cmd, out);
}
@ -222,6 +223,7 @@ static struct command_result *finish_txprepare(struct command *cmd,
out = jsonrpc_stream_success(cmd);
json_add_hex_talarr(out, "unsigned_tx", linearize_wtx(tmpctx, utx->tx));
json_add_txid(out, "txid", &utx->txid);
json_add_psbt(out, "psbt", utx->psbt);
return command_finished(cmd, out);
}