wallet: new commands 'txprepare', 'txsend' and 'txdiscard'.
This allows you to prepare a tx, then release or discard it later.
Shares almost all the code with json_withdraw (which is now technically
superfluous).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Config: Added a default plugin directory : `lightning_dir/plugins`. Each plugin directory it contains will be added to lightningd on startup.
- DB: Store the signatures of channel announcement sent from remote peer into DB, and init channel with signatures from DB directly when reenable the channel.
lightning-txdiscard \- Abandon a transaction from txprepare, release inputs
.SH"SYNOPSIS"
.sp
\fBtxdiscard\fR\fItxid\fR
.SH"DESCRIPTION"
.sp
The \fBtxdiscard\fR RPC command releases inputs which were reserved for use of the \fItxid\fR from lightning\-txprepare(7)\&.
.SH"RETURN VALUE"
.sp
On success, an object with attributes \fIunsigned_tx\fR and \fItxid\fR will be returned, exactly as from lightning\-txprepare(7)\&.
.sp
If there is no matching \fItxid\fR, an error is reported\&. Note that this may happen due to incorrect usage (such as \fBtxdiscard\fR or \fBtxsend\fR already being called for \fItxid\fR) or due to lightningd restarting, which implicitly calls \fBtxdiscard\fR on all outputs\&.
.sp
The following error codes may occur:
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\-1\&. An unknown
\fItxid\fR\&.
.RE
.SH"AUTHOR"
.sp
Rusty Russell <rusty@rustcorp\&.com\&.au> is mainly responsible\&.
.SH"SEE ALSO"
.sp
lightning\-txprepare(7), lightning\-txsend(7)
.SH"RESOURCES"
.sp
Main web site: https://github\&.com/ElementsProject/lightning
The \fBtxprepare\fR RPC command creates an unsigned transaction which spends funds from c\-lightning\(cqs internal wallet to the address specified in \fIdestination\fR\&.
.sp
Effectively, it is the first part of a \fBwithdraw\fR command, and uses the same parameters\&. The second part is provided by \fBtxsend\fR\&.
.SH"RETURN VALUE"
.sp
On success, an object with attributes \fIunsigned_tx\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\&.
.sp
\fIunsigned_tx\fR represents the raw bitcoin transaction (not yet signed) and \fItxid\fR represent the bitcoin transaction id\&.
.sp
On failure, an error is reported and the transaction is not created\&.
.sp
The following error codes may occur:
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\-1\&. Catchall nonspecific error\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
301\&. There are not enough funds in the internal wallet (including fees) to create the transaction\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
302\&. The dust limit is not met\&.
.RE
.SH"AUTHOR"
.sp
Rusty Russell <rusty@rustcorp\&.com\&.au> is mainly responsible\&.