sendpsbt, fundpsbt, utxopsbt, reserveinputs, unreserveinputs: allow custom number of blocks to reserve.

Not an API break: reserve=true|false still works for fundpsbt and utxopsbt,
but we also allow a raw number in there.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-05-26 10:49:37 +09:30
parent 95f77f119b
commit efe29c9db8
18 changed files with 257 additions and 177 deletions

View file

@ -1246,22 +1246,24 @@ class LightningRpc(UnixDomainSocketRpc):
}
return self.call("txsend", payload)
def reserveinputs(self, psbt, exclusive=True):
def reserveinputs(self, psbt, exclusive=True, reserve=None):
"""
Reserve any inputs in this psbt.
"""
payload = {
"psbt": psbt,
"exclusive": exclusive,
"reserve": reserve,
}
return self.call("reserveinputs", payload)
def unreserveinputs(self, psbt):
def unreserveinputs(self, psbt, reserve=None):
"""
Unreserve (or reduce reservation) on any UTXOs in this psbt were previously reserved.
"""
payload = {
"psbt": psbt,
"reserve": reserve,
}
return self.call("unreserveinputs", payload)
@ -1308,12 +1310,13 @@ class LightningRpc(UnixDomainSocketRpc):
}
return self.call("signpsbt", payload)
def sendpsbt(self, psbt):
def sendpsbt(self, psbt, reserve=None):
"""
Finalize extract and broadcast a PSBT
"""
payload = {
"psbt": psbt,
"reserve": reserve,
}
return self.call("sendpsbt", payload)

View file

@ -36,8 +36,10 @@ added any inputs\.
outputs should have\. Default is 1\.
\fIreserve\fR is a boolean: if true (the default), then \fIreserveinputs\fR is
called (successfully, with \fIexclusive\fR true) on the returned PSBT\.
\fIreserve\fR is either boolean or a number: if \fItrue\fR or a non-zero
number then \fIreserveinputs\fR is called (successfully, with
\fIexclusive\fR true) on the returned PSBT for this number of blocks (or
72 blocks if \fIreserve\fR is simply \fItrue\fR)\.
\fIlocktime\fR is an optional locktime: if not set, it is set to a recent
@ -85,8 +87,8 @@ then \fIexcess_msat\fR is the entire amount once fees are subtracted
for the weights of the inputs and startweight\.
If \fIreserve\fR was true, then a \fIreservations\fR array is returned,
exactly like \fIreserveinputs\fR\.
If \fIreserve\fR was \fItrue\fR or a non-zero number, then a \fIreservations\fR
array is returned, exactly like \fIreserveinputs\fR\.
If \fIexcess_as_change\fR is true and the excess is enough to cover
@ -120,4 +122,4 @@ Rusty Russell \fI<rusty@rustcorp.com.au\fR> is mainly responsible\.
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:b9ecd1408f0e5d8424e530ab44ab21b0e773c537c3512b68b31f197851d9abce
\" SHA256STAMP:6420ab94377f1a25df686e97e79da3c67c69f99978b6177432426dfd45296052

View file

@ -33,8 +33,10 @@ added any inputs.
*minconf* specifies the minimum number of confirmations that used
outputs should have. Default is 1.
*reserve* is a boolean: if true (the default), then *reserveinputs* is
called (successfully, with *exclusive* true) on the returned PSBT.
*reserve* is either boolean or a number: if *true* or a non-zero
number then *reserveinputs* is called (successfully, with
*exclusive* true) on the returned PSBT for this number of blocks (or
72 blocks if *reserve* is simply *true*).
*locktime* is an optional locktime: if not set, it is set to a recent
block height.
@ -77,8 +79,8 @@ available. This could be zero, or dust. If *satoshi* was "all",
then *excess_msat* is the entire amount once fees are subtracted
for the weights of the inputs and startweight.
If *reserve* was true, then a *reservations* array is returned,
exactly like *reserveinputs*.
If *reserve* was *true* or a non-zero number, then a *reservations*
array is returned, exactly like *reserveinputs*.
If *excess_as_change* is true and the excess is enough to cover
an additional output above the `dust_limit`, then an output is

View file

@ -3,7 +3,7 @@
lightning-reserveinputs - Construct a transaction and reserve the UTXOs it spends
.SH SYNOPSIS
\fBreserveinputs\fR \fIpsbt\fR [\fIexclusive\fR]
\fBreserveinputs\fR \fIpsbt\fR [\fIexclusive\fR] [\fIreserve\fR]
.SH DESCRIPTION
@ -17,6 +17,10 @@ Normally the command will fail (with no reservations made) if an input
is already reserved\. If \fIexclusive\fR is set to \fIFalse\fR, then existing
reservations are simply extended, rather than causing failure\.
By default, reservations are for the next 72 blocks (approximately 6
hours), but this can be changed by setting \fIreserve\fR\.
.SH RETURN VALUE
On success, a \fIreservations\fR array is returned, with an entry for each input
@ -58,4 +62,4 @@ niftynei \fI<niftynei@gmail.com\fR> is mainly responsible\.
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:539d241f86937d96dbc8a914f50a0cb920e7bee38b825502332a7755507f9e7b
\" SHA256STAMP:81be9e3af4075dd3bd24c6461861ee067b435654d88817afd0c49d37e85768a3

View file

@ -4,7 +4,7 @@ lightning-reserveinputs -- Construct a transaction and reserve the UTXOs it spen
SYNOPSIS
--------
**reserveinputs** *psbt* [*exclusive*]
**reserveinputs** *psbt* [*exclusive*] [*reserve*]
DESCRIPTION
-----------
@ -18,6 +18,8 @@ Normally the command will fail (with no reservations made) if an input
is already reserved. If *exclusive* is set to *False*, then existing
reservations are simply extended, rather than causing failure.
By default, reservations are for the next 72 blocks (approximately 6
hours), but this can be changed by setting *reserve*.
RETURN VALUE
------------

View file

@ -3,7 +3,7 @@
lightning-sendpsbt - Command to finalize, extract and send a partially signed bitcoin transaction (PSBT)\.
.SH SYNOPSIS
\fBsendpsbt\fR \fIpsbt\fR
\fBsendpsbt\fR \fIpsbt\fR [\fIreserve\fR]
.SH DESCRIPTION
@ -12,6 +12,8 @@ The \fBsendpsbt\fR is a low-level RPC command which sends a fully-signed PSBT\.
.RS
.IP \[bu]
\fIpsbt\fR: A string that represents psbt value\.
.IP \[bu]
\fIreserve\fR: an optional number of blocks to increase reservation of any of our inputs by; default is 72\.
.RE
.SH EXAMPLE JSON REQUEST
@ -68,4 +70,4 @@ Vincenzo Palazzo \fI<vincenzo.palazzo@protonmail.com\fR> wrote the initial versi
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:795058b68607af4148d2866faa88b3743269e1641725c95efcabdbe82c886420
\" SHA256STAMP:9241e9fa18b3a39ab64bfdfb875dc82ad5ccc242411ad265026005e69f29c2e0

View file

@ -4,7 +4,7 @@ lightning-sendpsbt -- Command to finalize, extract and send a partially signed b
SYNOPSIS
--------
**sendpsbt** *psbt*
**sendpsbt** *psbt* [*reserve*]
DESCRIPTION
-----------
@ -12,6 +12,7 @@ DESCRIPTION
The **sendpsbt** is a low-level RPC command which sends a fully-signed PSBT.
- *psbt*: A string that represents psbt value.
- *reserve*: an optional number of blocks to increase reservation of any of our inputs by; default is 72.
EXAMPLE JSON REQUEST
--------------------

View file

@ -3,7 +3,7 @@
lightning-unreserveinputs - Release reserved UTXOs
.SH SYNOPSIS
\fBunreserveinputs\fR \fIpsbt\fR
\fBunreserveinputs\fR \fIpsbt\fR [\fIreserve\fR]
.SH DESCRIPTION
@ -14,6 +14,10 @@ on UTXOs which were previously marked as reserved, generally by
The inputs to unreserve are the inputs specified in the passed-in \fIpsbt\fR\.
If \fIreserve\fR is specified, it is the number of blocks to decrease
reservation by; default is 72\.
.SH RETURN VALUE
On success, an \fIreservations\fR array is returned, with an entry for each input
@ -55,4 +59,4 @@ niftynei \fI<niftynei@gmail.com\fR> is mainly responsible\.
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:2f6d02c98127f7ab54e5c298761be2c4138f79fd6c156eed9ae19ead03db8593
\" SHA256STAMP:d4aa9d3345ce7fa3c91b760633c3dc296d4dd7a7da7cdadc4da31c3b474e680c

View file

@ -4,7 +4,7 @@ lightning-unreserveinputs -- Release reserved UTXOs
SYNOPSIS
--------
**unreserveinputs** *psbt*
**unreserveinputs** *psbt* [*reserve*]
DESCRIPTION
-----------
@ -15,6 +15,9 @@ lightning-reserveinputs(7).
The inputs to unreserve are the inputs specified in the passed-in *psbt*.
If *reserve* is specified, it is the number of blocks to decrease
reservation by; default is 72.
RETURN VALUE
------------

View file

@ -24,6 +24,12 @@ with at least \fIsatoshi\fR left over (unless \fIsatoshi\fR is \fBall\fR, which
is equivalent to setting it to zero)\.
\fIreserve\fR is either boolean or a number: if \fItrue\fR or a non-zero
number then \fIreserveinputs\fR is called (successfully, with
\fIexclusive\fR true) on the returned PSBT for this number of blocks (or
72 blocks if \fIreserve\fR is simply \fItrue\fR)\.
Unless \fIreservedok\fR is set to true (default is false) it will also fail
if any of the \fIutxos\fR are already reserved\.
@ -51,8 +57,8 @@ then \fIexcess_msat\fR is the entire amount once fees are subtracted
for the weights of the inputs and \fIstartweight\fR\.
If \fIreserve\fR was true, then a \fIreservations\fR array is returned,
exactly like \fIreserveinputs\fR\.
If \fIreserve\fR was \fItrue\fR or a non-zero number, then a \fIreservations\fR
array is returned, exactly like \fIreserveinputs\fR\.
If \fIexcess_as_change\fR is true and the excess is enough to cover
@ -86,4 +92,4 @@ Rusty Russell \fI<rusty@rustcorp.com.au\fR> is mainly responsible\.
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:f956240b56534af4f6e99e3e77bbb4f5bc707c390a935cde08be0178abbb9cbd
\" SHA256STAMP:fb64856561ee499c033582b483e676354a98fb500136a8d52c857981f33339ea

View file

@ -23,6 +23,11 @@ the resulting transaction plus *startweight* at the given *feerate*,
with at least *satoshi* left over (unless *satoshi* is **all**, which
is equivalent to setting it to zero).
*reserve* is either boolean or a number: if *true* or a non-zero
number then *reserveinputs* is called (successfully, with
*exclusive* true) on the returned PSBT for this number of blocks (or
72 blocks if *reserve* is simply *true*).
Unless *reservedok* is set to true (default is false) it will also fail
if any of the *utxos* are already reserved.
@ -47,8 +52,8 @@ which is available. This could be zero, or dust. If *satoshi* was "all",
then *excess_msat* is the entire amount once fees are subtracted
for the weights of the inputs and *startweight*.
If *reserve* was true, then a *reservations* array is returned,
exactly like *reserveinputs*.
If *reserve* was *true* or a non-zero number, then a *reservations*
array is returned, exactly like *reserveinputs*.
If *excess_as_change* is true and the excess is enough to cover
an additional output above the `dust_limit`, then an output is

View file

@ -1906,4 +1906,4 @@ struct db_query db_postgres_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
// SHA256STAMP:0e328ae08429373c5aa43797ae12be23e5b6c3d7e2f06123c2640a1a42ac79ee
// SHA256STAMP:387f4000b85417999e9b27c6d795d4f19012a5515e2464312e865b7f654d70dd

View file

@ -1906,4 +1906,4 @@ struct db_query db_sqlite3_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
// SHA256STAMP:0e328ae08429373c5aa43797ae12be23e5b6c3d7e2f06123c2640a1a42ac79ee
// SHA256STAMP:387f4000b85417999e9b27c6d795d4f19012a5515e2464312e865b7f654d70dd

View file

@ -12,6 +12,9 @@
#include <wallet/wallet.h>
#include <wallet/walletrpc.h>
/* 12 hours is usually enough reservation time */
#define RESERVATION_DEFAULT (6 * 12)
static bool was_reserved(enum output_status oldstatus,
u32 reserved_til,
u32 current_height)
@ -45,6 +48,7 @@ static void json_add_reservestatus(struct json_stream *response,
static void reserve_and_report(struct json_stream *response,
struct wallet *wallet,
u32 current_height,
u32 reserve,
struct utxo **utxos)
{
json_array_start(response, "reservations");
@ -57,7 +61,8 @@ static void reserve_and_report(struct json_stream *response,
if (!wallet_reserve_utxo(wallet,
utxos[i],
current_height)) {
current_height,
reserve)) {
fatal("Unable to reserve %s:%u!",
type_to_string(tmpctx,
struct bitcoin_txid,
@ -79,11 +84,13 @@ static struct command_result *json_reserveinputs(struct command *cmd,
struct wally_psbt *psbt;
struct utxo **utxos = tal_arr(cmd, struct utxo *, 0);
bool *exclusive;
u32 current_height;
u32 *reserve, current_height;
if (!param(cmd, buffer, params,
p_req("psbt", param_psbt, &psbt),
p_opt_def("exclusive", param_bool, &exclusive, true),
p_opt_def("reserve", param_number, &reserve,
RESERVATION_DEFAULT),
NULL))
return command_param_failed();
@ -116,7 +123,7 @@ static struct command_result *json_reserveinputs(struct command *cmd,
}
response = json_stream_success(cmd);
reserve_and_report(response, cmd->ld->wallet, current_height, utxos);
reserve_and_report(response, cmd->ld->wallet, current_height, *reserve, utxos);
return command_success(cmd, response);
}
@ -136,9 +143,12 @@ static struct command_result *json_unreserveinputs(struct command *cmd,
{
struct json_stream *response;
struct wally_psbt *psbt;
u32 *reserve;
if (!param(cmd, buffer, params,
p_req("psbt", param_psbt, &psbt),
p_opt_def("reserve", param_number, &reserve,
RESERVATION_DEFAULT),
NULL))
return command_param_failed();
@ -183,7 +193,8 @@ static struct command_result *json_unreserveinputs(struct command *cmd,
wallet_unreserve_utxo(cmd->ld->wallet,
utxo,
get_block_height(cmd->ld->topology));
get_block_height(cmd->ld->topology),
*reserve);
json_add_reservestatus(response, utxo, oldstatus, old_res,
get_block_height(cmd->ld->topology));
@ -319,7 +330,7 @@ static struct command_result *finish_psbt(struct command *cmd,
u32 feerate_per_kw,
size_t weight,
struct amount_sat excess,
bool reserve,
u32 reserve,
u32 *locktime,
bool excess_as_change)
{
@ -405,7 +416,7 @@ fee_calc:
json_add_num(response, "change_outnum", change_outnum);
if (reserve)
reserve_and_report(response, cmd->ld->wallet, current_height,
utxos);
reserve, utxos);
return command_success(cmd, response);
}
@ -424,6 +435,27 @@ static inline u32 minconf_to_maxheight(u32 minconf, struct lightningd *ld)
return ld->topology->tip->height - minconf + 1;
}
static struct command_result *param_reserve_num(struct command *cmd,
const char *name,
const char *buffer,
const jsmntok_t *tok,
unsigned int **num)
{
bool flag;
/* "reserve=true" means 6 hours */
if (json_to_bool(buffer, tok, &flag)) {
*num = tal(cmd, unsigned int);
if (flag)
**num = RESERVATION_DEFAULT;
else
**num = 0;
return NULL;
}
return param_number(cmd, name, buffer, tok, num);
}
static struct command_result *json_fundpsbt(struct command *cmd,
const char *buffer,
const jsmntok_t *obj UNNEEDED,
@ -433,15 +465,16 @@ static struct command_result *json_fundpsbt(struct command *cmd,
u32 *feerate_per_kw;
u32 *minconf, *weight, *min_witness_weight;
struct amount_sat *amount, input, diff;
bool all, *reserve, *excess_as_change;
u32 *locktime, maxheight;
bool all, *excess_as_change;
u32 *locktime, *reserve, maxheight;
if (!param(cmd, buffer, params,
p_req("satoshi", param_sat_or_all, &amount),
p_req("feerate", param_feerate, &feerate_per_kw),
p_req("startweight", param_number, &weight),
p_opt_def("minconf", param_number, &minconf, 1),
p_opt_def("reserve", param_bool, &reserve, true),
p_opt_def("reserve", param_reserve_num, &reserve,
RESERVATION_DEFAULT),
p_opt("locktime", param_number, &locktime),
p_opt_def("min_witness_weight", param_number,
&min_witness_weight, 0),
@ -615,16 +648,17 @@ static struct command_result *json_utxopsbt(struct command *cmd,
{
struct utxo **utxos;
u32 *feerate_per_kw, *weight, *min_witness_weight;
bool all, *reserve, *reserved_ok, *excess_as_change;
bool all, *reserved_ok, *excess_as_change;
struct amount_sat *amount, input, excess;
u32 current_height, *locktime;
u32 current_height, *locktime, *reserve;
if (!param(cmd, buffer, params,
p_req("satoshi", param_sat_or_all, &amount),
p_req("feerate", param_feerate, &feerate_per_kw),
p_req("startweight", param_number, &weight),
p_req("utxos", param_txout, &utxos),
p_opt_def("reserve", param_bool, &reserve, true),
p_opt_def("reserve", param_reserve_num, &reserve,
RESERVATION_DEFAULT),
p_opt_def("reservedok", param_bool, &reserved_ok, false),
p_opt("locktime", param_number, &locktime),
p_opt_def("min_witness_weight", param_number,

View file

@ -758,487 +758,487 @@ msgstr ""
msgid "SELECT state, payment_key, payment_hash, label, msatoshi, expiry_time, pay_index, msatoshi_received, paid_timestamp, bolt11, description, features, local_offer_id FROM invoices WHERE id = ?;"
msgstr ""
#: wallet/wallet.c:50
#: wallet/wallet.c:47
msgid "SELECT txid, outnum FROM utxoset WHERE spendheight is NULL"
msgstr ""
#: wallet/wallet.c:91 wallet/wallet.c:569
#: wallet/wallet.c:88 wallet/wallet.c:570
msgid "SELECT * from outputs WHERE prev_out_tx=? AND prev_out_index=?"
msgstr ""
#: wallet/wallet.c:105 wallet/wallet.c:583
#: wallet/wallet.c:102 wallet/wallet.c:584
msgid "INSERT INTO outputs ( prev_out_tx, prev_out_index, value, type, status, keyindex, channel_id, peer_id, commitment_point, option_anchor_outputs, confirmation_height, spend_height, scriptpubkey) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"
msgstr ""
#: wallet/wallet.c:222
#: wallet/wallet.c:219
msgid "UPDATE outputs SET status=? WHERE status=? AND prev_out_tx=? AND prev_out_index=?"
msgstr ""
#: wallet/wallet.c:230
#: wallet/wallet.c:227
msgid "UPDATE outputs SET status=? WHERE prev_out_tx=? AND prev_out_index=?"
msgstr ""
#: wallet/wallet.c:249
#: wallet/wallet.c:246
msgid "SELECT prev_out_tx, prev_out_index, value, type, status, keyindex, channel_id, peer_id, commitment_point, option_anchor_outputs, confirmation_height, spend_height, scriptpubkey , reserved_til FROM outputs"
msgstr ""
#: wallet/wallet.c:266
#: wallet/wallet.c:263
msgid "SELECT prev_out_tx, prev_out_index, value, type, status, keyindex, channel_id, peer_id, commitment_point, option_anchor_outputs, confirmation_height, spend_height, scriptpubkey , reserved_til FROM outputs WHERE status= ? "
msgstr ""
#: wallet/wallet.c:304
#: wallet/wallet.c:301
msgid "SELECT prev_out_tx, prev_out_index, value, type, status, keyindex, channel_id, peer_id, commitment_point, option_anchor_outputs, confirmation_height, spend_height, scriptpubkey, reserved_til FROM outputs WHERE channel_id IS NOT NULL AND confirmation_height IS NULL"
msgstr ""
#: wallet/wallet.c:341
#: wallet/wallet.c:338
msgid "SELECT prev_out_tx, prev_out_index, value, type, status, keyindex, channel_id, peer_id, commitment_point, option_anchor_outputs, confirmation_height, spend_height, scriptpubkey, reserved_til FROM outputs WHERE prev_out_tx = ? AND prev_out_index = ?"
msgstr ""
#: wallet/wallet.c:433
#: wallet/wallet.c:430
msgid "UPDATE outputs SET status=?, reserved_til=? WHERE prev_out_tx=? AND prev_out_index=?"
msgstr ""
#: wallet/wallet.c:518
#: wallet/wallet.c:519
msgid "SELECT prev_out_tx, prev_out_index, value, type, status, keyindex, channel_id, peer_id, commitment_point, option_anchor_outputs, confirmation_height, spend_height, scriptpubkey , reserved_til FROM outputs WHERE status = ? OR (status = ? AND reserved_til <= ?)ORDER BY RANDOM();"
msgstr ""
#: wallet/wallet.c:687
#: wallet/wallet.c:688
msgid "INSERT INTO shachains (min_index, num_valid) VALUES (?, 0);"
msgstr ""
#: wallet/wallet.c:731
#: wallet/wallet.c:732
msgid "UPDATE shachains SET num_valid=?, min_index=? WHERE id=?"
msgstr ""
#: wallet/wallet.c:738
#: wallet/wallet.c:739
msgid "UPDATE shachain_known SET idx=?, hash=? WHERE shachain_id=? AND pos=?"
msgstr ""
#: wallet/wallet.c:750
#: wallet/wallet.c:751
msgid "INSERT INTO shachain_known (shachain_id, pos, idx, hash) VALUES (?, ?, ?, ?);"
msgstr ""
#: wallet/wallet.c:772
#: wallet/wallet.c:773
msgid "SELECT min_index, num_valid FROM shachains WHERE id=?"
msgstr ""
#: wallet/wallet.c:787
#: wallet/wallet.c:788
msgid "SELECT idx, hash, pos FROM shachain_known WHERE shachain_id=?"
msgstr ""
#: wallet/wallet.c:810
#: wallet/wallet.c:811
msgid "SELECT id, node_id, address FROM peers WHERE id=?;"
msgstr ""
#: wallet/wallet.c:843
#: wallet/wallet.c:844
msgid "SELECT signature FROM htlc_sigs WHERE channelid = ?"
msgstr ""
#: wallet/wallet.c:877
#: wallet/wallet.c:878
msgid "SELECT remote_ann_node_sig, remote_ann_bitcoin_sig FROM channels WHERE id = ?"
msgstr ""
#: wallet/wallet.c:921
#: wallet/wallet.c:922
msgid "SELECT hstate, feerate_per_kw FROM channel_feerates WHERE channel_id = ?"
msgstr ""
#: wallet/wallet.c:954
#: wallet/wallet.c:955
msgid "INSERT INTO channel_funding_inflights ( channel_id, funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"
msgstr ""
#: wallet/wallet.c:989
#: wallet/wallet.c:990
msgid "UPDATE channel_funding_inflights SET funding_psbt=?, funding_tx_remote_sigs_received=? WHERE channel_id=? AND funding_tx_id=? AND funding_tx_outnum=?"
msgstr ""
#: wallet/wallet.c:1012
#: wallet/wallet.c:1013
msgid "DELETE FROM channel_funding_inflights WHERE channel_id = ?"
msgstr ""
#: wallet/wallet.c:1060
#: wallet/wallet.c:1061
msgid "SELECT funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, funding_tx_remote_sigs_received FROM channel_funding_inflights WHERE channel_id = ? ORDER BY funding_feerate"
msgstr ""
#: wallet/wallet.c:1289
#: wallet/wallet.c:1290
msgid "SELECT id FROM channels ORDER BY id DESC LIMIT 1;"
msgstr ""
#: wallet/wallet.c:1306
#: wallet/wallet.c:1307
msgid "SELECT id, peer_id, short_channel_id, full_channel_id, channel_config_local, channel_config_remote, state, funder, channel_flags, minimum_depth, next_index_local, next_index_remote, next_htlc_id, funding_tx_id, funding_tx_outnum, funding_satoshi, our_funding_satoshi, funding_locked_remote, push_msatoshi, msatoshi_local, fundingkey_remote, revocation_basepoint_remote, payment_basepoint_remote, htlc_basepoint_remote, delayed_payment_basepoint_remote, per_commit_remote, old_per_commit_remote, local_feerate_per_kw, remote_feerate_per_kw, shachain_remote_id, shutdown_scriptpubkey_remote, shutdown_keyidx_local, last_sent_commit_state, last_sent_commit_id, last_tx, last_sig, last_was_revoke, first_blocknum, min_possible_feerate, max_possible_feerate, msatoshi_to_us_min, msatoshi_to_us_max, future_per_commitment_point, last_sent_commit, feerate_base, feerate_ppm, remote_upfront_shutdown_script, option_static_remotekey, option_anchor_outputs, shutdown_scriptpubkey_local, closer, state_change_reason, revocation_basepoint_local, payment_basepoint_local, htlc_basepoint_local, delayed_payment_basepoint_local, funding_pubkey_local, shutdown_wrong_txid, shutdown_wrong_outnum FROM channels WHERE state != ?;"
msgstr ""
#: wallet/wallet.c:1404
#: wallet/wallet.c:1405
msgid "UPDATE channels SET in_payments_offered = COALESCE(in_payments_offered, 0) + 1 , in_msatoshi_offered = COALESCE(in_msatoshi_offered, 0) + ? WHERE id = ?;"
msgstr ""
#: wallet/wallet.c:1409
#: wallet/wallet.c:1410
msgid "UPDATE channels SET in_payments_fulfilled = COALESCE(in_payments_fulfilled, 0) + 1 , in_msatoshi_fulfilled = COALESCE(in_msatoshi_fulfilled, 0) + ? WHERE id = ?;"
msgstr ""
#: wallet/wallet.c:1414
#: wallet/wallet.c:1415
msgid "UPDATE channels SET out_payments_offered = COALESCE(out_payments_offered, 0) + 1 , out_msatoshi_offered = COALESCE(out_msatoshi_offered, 0) + ? WHERE id = ?;"
msgstr ""
#: wallet/wallet.c:1419
#: wallet/wallet.c:1420
msgid "UPDATE channels SET out_payments_fulfilled = COALESCE(out_payments_fulfilled, 0) + 1 , out_msatoshi_fulfilled = COALESCE(out_msatoshi_fulfilled, 0) + ? WHERE id = ?;"
msgstr ""
#: wallet/wallet.c:1461
#: wallet/wallet.c:1462
msgid "SELECT in_payments_offered, in_payments_fulfilled, in_msatoshi_offered, in_msatoshi_fulfilled, out_payments_offered, out_payments_fulfilled, out_msatoshi_offered, out_msatoshi_fulfilled FROM channels WHERE id = ?"
msgstr ""
#: wallet/wallet.c:1490
#: wallet/wallet.c:1491
msgid "SELECT MIN(height), MAX(height) FROM blocks;"
msgstr ""
#: wallet/wallet.c:1512
#: wallet/wallet.c:1513
msgid "INSERT INTO channel_configs DEFAULT VALUES;"
msgstr ""
#: wallet/wallet.c:1524
#: wallet/wallet.c:1525
msgid "UPDATE channel_configs SET dust_limit_satoshis=?, max_htlc_value_in_flight_msat=?, channel_reserve_satoshis=?, htlc_minimum_msat=?, to_self_delay=?, max_accepted_htlcs=? WHERE id=?;"
msgstr ""
#: wallet/wallet.c:1548
#: wallet/wallet.c:1549
msgid "SELECT id, dust_limit_satoshis, max_htlc_value_in_flight_msat, channel_reserve_satoshis, htlc_minimum_msat, to_self_delay, max_accepted_htlcs FROM channel_configs WHERE id= ? ;"
msgstr ""
#: wallet/wallet.c:1582
#: wallet/wallet.c:1583
msgid "UPDATE channels SET remote_ann_node_sig=?, remote_ann_bitcoin_sig=? WHERE id=?"
msgstr ""
#: wallet/wallet.c:1601
#: wallet/wallet.c:1602
msgid "UPDATE channels SET shachain_remote_id=?, short_channel_id=?, full_channel_id=?, state=?, funder=?, channel_flags=?, minimum_depth=?, next_index_local=?, next_index_remote=?, next_htlc_id=?, funding_tx_id=?, funding_tx_outnum=?, funding_satoshi=?, our_funding_satoshi=?, funding_locked_remote=?, push_msatoshi=?, msatoshi_local=?, shutdown_scriptpubkey_remote=?, shutdown_keyidx_local=?, channel_config_local=?, last_tx=?, last_sig=?, last_was_revoke=?, min_possible_feerate=?, max_possible_feerate=?, msatoshi_to_us_min=?, msatoshi_to_us_max=?, feerate_base=?, feerate_ppm=?, remote_upfront_shutdown_script=?, option_static_remotekey=?, option_anchor_outputs=?, shutdown_scriptpubkey_local=?, closer=?, state_change_reason=?, shutdown_wrong_txid=?, shutdown_wrong_outnum=? WHERE id=?"
msgstr ""
#: wallet/wallet.c:1693
#: wallet/wallet.c:1694
msgid "UPDATE channels SET fundingkey_remote=?, revocation_basepoint_remote=?, payment_basepoint_remote=?, htlc_basepoint_remote=?, delayed_payment_basepoint_remote=?, per_commit_remote=?, old_per_commit_remote=?, channel_config_remote=?, future_per_commitment_point=? WHERE id=?"
msgstr ""
#: wallet/wallet.c:1720
#: wallet/wallet.c:1721
msgid "DELETE FROM channel_feerates WHERE channel_id=?"
msgstr ""
#: wallet/wallet.c:1730
#: wallet/wallet.c:1731
msgid "INSERT INTO channel_feerates VALUES(?, ?, ?)"
msgstr ""
#: wallet/wallet.c:1747
#: wallet/wallet.c:1748
msgid "UPDATE channels SET last_sent_commit=? WHERE id=?"
msgstr ""
#: wallet/wallet.c:1770
#: wallet/wallet.c:1771
msgid "INSERT INTO channel_state_changes ( channel_id, timestamp, old_state, new_state, cause, message) VALUES (?, ?, ?, ?, ?, ?);"
msgstr ""
#: wallet/wallet.c:1798
#: wallet/wallet.c:1799
msgid "SELECT timestamp, old_state, new_state, cause, message FROM channel_state_changes WHERE channel_id = ? ORDER BY timestamp ASC;"
msgstr ""
#: wallet/wallet.c:1827
#: wallet/wallet.c:1828
msgid "SELECT id FROM peers WHERE node_id = ?"
msgstr ""
#: wallet/wallet.c:1839
#: wallet/wallet.c:1840
msgid "UPDATE peers SET address = ? WHERE id = ?"
msgstr ""
#: wallet/wallet.c:1848
#: wallet/wallet.c:1849
msgid "INSERT INTO peers (node_id, address) VALUES (?, ?);"
msgstr ""
#: wallet/wallet.c:1869
#: wallet/wallet.c:1870
msgid "INSERT INTO channels ( peer_id, first_blocknum, id, revocation_basepoint_local, payment_basepoint_local, htlc_basepoint_local, delayed_payment_basepoint_local, funding_pubkey_local) VALUES (?, ?, ?, ?, ?, ?, ?, ?);"
msgstr ""
#: wallet/wallet.c:1910
#: wallet/wallet.c:1911
msgid "DELETE FROM channel_htlcs WHERE channel_id=?"
msgstr ""
#: wallet/wallet.c:1916
#: wallet/wallet.c:1917
msgid "DELETE FROM htlc_sigs WHERE channelid=?"
msgstr ""
#: wallet/wallet.c:1922
#: wallet/wallet.c:1923
msgid "DELETE FROM channeltxs WHERE channel_id=?"
msgstr ""
#: wallet/wallet.c:1929
#: wallet/wallet.c:1930
msgid "DELETE FROM channel_funding_inflights WHERE channel_id=?"
msgstr ""
#: wallet/wallet.c:1935
#: wallet/wallet.c:1936
msgid "DELETE FROM shachains WHERE id IN ( SELECT shachain_remote_id FROM channels WHERE channels.id=?)"
msgstr ""
#: wallet/wallet.c:1945
#: wallet/wallet.c:1946
msgid "UPDATE channels SET state=?, peer_id=? WHERE channels.id=?"
msgstr ""
#: wallet/wallet.c:1959
#: wallet/wallet.c:1960
msgid "SELECT * FROM channels WHERE peer_id = ?;"
msgstr ""
#: wallet/wallet.c:1967
#: wallet/wallet.c:1968
msgid "DELETE FROM peers WHERE id=?"
msgstr ""
#: wallet/wallet.c:1978
#: wallet/wallet.c:1979
msgid "UPDATE outputs SET confirmation_height = ? WHERE prev_out_tx = ?"
msgstr ""
#: wallet/wallet.c:2081
#: wallet/wallet.c:2082
msgid "INSERT INTO channel_htlcs ( channel_id, channel_htlc_id, direction, msatoshi, cltv_expiry, payment_hash, payment_key, hstate, shared_secret, routing_onion, received_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"
msgstr ""
#: wallet/wallet.c:2134
#: wallet/wallet.c:2135
msgid "INSERT INTO channel_htlcs ( channel_id, channel_htlc_id, direction, origin_htlc, msatoshi, cltv_expiry, payment_hash, payment_key, hstate, routing_onion, malformed_onion, partid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?);"
msgstr ""
#: wallet/wallet.c:2195
#: wallet/wallet.c:2196
msgid "UPDATE channel_htlcs SET hstate=?, payment_key=?, malformed_onion=?, failuremsg=?, localfailmsg=?, we_filled=? WHERE id=?"
msgstr ""
#: wallet/wallet.c:2411
#: wallet/wallet.c:2412
msgid "SELECT id, channel_htlc_id, msatoshi, cltv_expiry, hstate, payment_hash, payment_key, routing_onion, failuremsg, malformed_onion, origin_htlc, shared_secret, received_time, we_filled FROM channel_htlcs WHERE direction= ? AND channel_id= ? AND hstate != ?"
msgstr ""
#: wallet/wallet.c:2458
#: wallet/wallet.c:2459
msgid "SELECT id, channel_htlc_id, msatoshi, cltv_expiry, hstate, payment_hash, payment_key, routing_onion, failuremsg, malformed_onion, origin_htlc, shared_secret, received_time, partid, localfailmsg FROM channel_htlcs WHERE direction = ? AND channel_id = ? AND hstate != ?"
msgstr ""
#: wallet/wallet.c:2589
#: wallet/wallet.c:2590
msgid "SELECT channel_id, direction, cltv_expiry, channel_htlc_id, payment_hash FROM channel_htlcs WHERE channel_id = ?;"
msgstr ""
#: wallet/wallet.c:2623
#: wallet/wallet.c:2624
msgid "DELETE FROM channel_htlcs WHERE direction = ? AND origin_htlc = ? AND payment_hash = ? AND partid = ?;"
msgstr ""
#: wallet/wallet.c:2676
#: wallet/wallet.c:2677
msgid "SELECT status FROM payments WHERE payment_hash=? AND partid = ?;"
msgstr ""
#: wallet/wallet.c:2694
#: wallet/wallet.c:2695
msgid "INSERT INTO payments ( status, payment_hash, destination, msatoshi, timestamp, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, total_msat, partid, local_offer_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"
msgstr ""
#: wallet/wallet.c:2783
#: wallet/wallet.c:2784
msgid "DELETE FROM payments WHERE payment_hash = ? AND partid = ?"
msgstr ""
#: wallet/wallet.c:2797
#: wallet/wallet.c:2798
msgid "DELETE FROM payments WHERE payment_hash = ?"
msgstr ""
#: wallet/wallet.c:2898
#: wallet/wallet.c:2899
msgid "SELECT id, status, destination, msatoshi, payment_hash, timestamp, payment_preimage, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, failonionreply, total_msat, partid, local_offer_id FROM payments WHERE payment_hash = ? AND partid = ?"
msgstr ""
#: wallet/wallet.c:2948
#: wallet/wallet.c:2949
msgid "UPDATE payments SET status=? WHERE payment_hash=? AND partid=?"
msgstr ""
#: wallet/wallet.c:2958
#: wallet/wallet.c:2959
msgid "UPDATE payments SET payment_preimage=? WHERE payment_hash=? AND partid=?"
msgstr ""
#: wallet/wallet.c:2968
#: wallet/wallet.c:2969
msgid "UPDATE payments SET path_secrets = NULL , route_nodes = NULL , route_channels = NULL WHERE payment_hash = ? AND partid = ?;"
msgstr ""
#: wallet/wallet.c:3000
#: wallet/wallet.c:3001
msgid "SELECT failonionreply, faildestperm, failindex, failcode, failnode, failchannel, failupdate, faildetail, faildirection FROM payments WHERE payment_hash=? AND partid=?;"
msgstr ""
#: wallet/wallet.c:3067
#: wallet/wallet.c:3068
msgid "UPDATE payments SET failonionreply=? , faildestperm=? , failindex=? , failcode=? , failnode=? , failchannel=? , failupdate=? , faildetail=? , faildirection=? WHERE payment_hash=? AND partid=?;"
msgstr ""
#: wallet/wallet.c:3126
#: wallet/wallet.c:3127
msgid "SELECT id, status, destination, msatoshi, payment_hash, timestamp, payment_preimage, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, failonionreply, total_msat, partid, local_offer_id FROM payments WHERE payment_hash = ?;"
msgstr ""
#: wallet/wallet.c:3148
#: wallet/wallet.c:3149
msgid "SELECT id, status, destination, msatoshi, payment_hash, timestamp, payment_preimage, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, failonionreply, total_msat, partid, local_offer_id FROM payments ORDER BY id;"
msgstr ""
#: wallet/wallet.c:3199
#: wallet/wallet.c:3200
msgid "SELECT id, status, destination, msatoshi, payment_hash, timestamp, payment_preimage, path_secrets, route_nodes, route_channels, msatoshi_sent, description, bolt11, failonionreply, total_msat, partid, local_offer_id FROM payments WHERE local_offer_id = ?;"
msgstr ""
#: wallet/wallet.c:3244
#: wallet/wallet.c:3245
msgid "DELETE FROM htlc_sigs WHERE channelid = ?"
msgstr ""
#: wallet/wallet.c:3251
#: wallet/wallet.c:3252
msgid "INSERT INTO htlc_sigs (channelid, signature) VALUES (?, ?)"
msgstr ""
#: wallet/wallet.c:3263
#: wallet/wallet.c:3264
msgid "SELECT blobval FROM vars WHERE name='genesis_hash'"
msgstr ""
#: wallet/wallet.c:3287
#: wallet/wallet.c:3288
msgid "INSERT INTO vars (name, blobval) VALUES ('genesis_hash', ?);"
msgstr ""
#: wallet/wallet.c:3305
#: wallet/wallet.c:3306
msgid "SELECT txid, outnum FROM utxoset WHERE spendheight < ?"
msgstr ""
#: wallet/wallet.c:3317
#: wallet/wallet.c:3318
msgid "DELETE FROM utxoset WHERE spendheight < ?"
msgstr ""
#: wallet/wallet.c:3325 wallet/wallet.c:3439
#: wallet/wallet.c:3326 wallet/wallet.c:3440
msgid "INSERT INTO blocks (height, hash, prev_hash) VALUES (?, ?, ?);"
msgstr ""
#: wallet/wallet.c:3344
#: wallet/wallet.c:3345
msgid "DELETE FROM blocks WHERE hash = ?"
msgstr ""
#: wallet/wallet.c:3350
#: wallet/wallet.c:3351
msgid "SELECT * FROM blocks WHERE height >= ?;"
msgstr ""
#: wallet/wallet.c:3359
#: wallet/wallet.c:3360
msgid "DELETE FROM blocks WHERE height > ?"
msgstr ""
#: wallet/wallet.c:3371
#: wallet/wallet.c:3372
msgid "UPDATE outputs SET spend_height = ?, status = ? WHERE prev_out_tx = ? AND prev_out_index = ?"
msgstr ""
#: wallet/wallet.c:3389
#: wallet/wallet.c:3390
msgid "UPDATE utxoset SET spendheight = ? WHERE txid = ? AND outnum = ?"
msgstr ""
#: wallet/wallet.c:3412 wallet/wallet.c:3450
#: wallet/wallet.c:3413 wallet/wallet.c:3451
msgid "INSERT INTO utxoset ( txid, outnum, blockheight, spendheight, txindex, scriptpubkey, satoshis) VALUES(?, ?, ?, ?, ?, ?, ?);"
msgstr ""
#: wallet/wallet.c:3476
#: wallet/wallet.c:3477
msgid "SELECT height FROM blocks WHERE height = ?"
msgstr ""
#: wallet/wallet.c:3489
#: wallet/wallet.c:3490
msgid "SELECT txid, spendheight, scriptpubkey, satoshis FROM utxoset WHERE blockheight = ? AND txindex = ? AND outnum = ? AND spendheight IS NULL"
msgstr ""
#: wallet/wallet.c:3531
#: wallet/wallet.c:3532
msgid "SELECT blockheight, txindex, outnum FROM utxoset WHERE spendheight = ?"
msgstr ""
#: wallet/wallet.c:3562 wallet/wallet.c:3722
#: wallet/wallet.c:3563 wallet/wallet.c:3723
msgid "SELECT blockheight FROM transactions WHERE id=?"
msgstr ""
#: wallet/wallet.c:3572
#: wallet/wallet.c:3573
msgid "INSERT INTO transactions ( id, blockheight, txindex, rawtx) VALUES (?, ?, ?, ?);"
msgstr ""
#: wallet/wallet.c:3593
#: wallet/wallet.c:3594
msgid "UPDATE transactions SET blockheight = ?, txindex = ? WHERE id = ?"
msgstr ""
#: wallet/wallet.c:3610
#: wallet/wallet.c:3611
msgid "INSERT INTO transaction_annotations (txid, idx, location, type, channel) VALUES (?, ?, ?, ?, ?) ON CONFLICT(txid,idx) DO NOTHING;"
msgstr ""
#: wallet/wallet.c:3642
#: wallet/wallet.c:3643
msgid "SELECT type, channel_id FROM transactions WHERE id=?"
msgstr ""
#: wallet/wallet.c:3658
#: wallet/wallet.c:3659
msgid "UPDATE transactions SET type = ?, channel_id = ? WHERE id = ?"
msgstr ""
#: wallet/wallet.c:3677
#: wallet/wallet.c:3678
msgid "SELECT type FROM transactions WHERE id=?"
msgstr ""
#: wallet/wallet.c:3700
#: wallet/wallet.c:3701
msgid "SELECT rawtx FROM transactions WHERE id=?"
msgstr ""
#: wallet/wallet.c:3746
#: wallet/wallet.c:3747
msgid "SELECT blockheight, txindex FROM transactions WHERE id=?"
msgstr ""
#: wallet/wallet.c:3774
#: wallet/wallet.c:3775
msgid "SELECT id FROM transactions WHERE blockheight=?"
msgstr ""
#: wallet/wallet.c:3793
#: wallet/wallet.c:3794
msgid "INSERT INTO channeltxs ( channel_id, type, transaction_id, input_num, blockheight) VALUES (?, ?, ?, ?, ?);"
msgstr ""
#: wallet/wallet.c:3817
#: wallet/wallet.c:3818
msgid "SELECT DISTINCT(channel_id) FROM channeltxs WHERE type = ?;"
msgstr ""
#: wallet/wallet.c:3838
#: wallet/wallet.c:3839
msgid "SELECT c.type, c.blockheight, t.rawtx, c.input_num, c.blockheight - t.blockheight + 1 AS depth, t.id as txid FROM channeltxs c JOIN transactions t ON t.id = c.transaction_id WHERE c.channel_id = ? ORDER BY c.id ASC;"
msgstr ""
#: wallet/wallet.c:3883
#: wallet/wallet.c:3884
msgid "UPDATE forwarded_payments SET in_msatoshi=?, out_msatoshi=?, state=?, resolved_time=?, failcode=? WHERE in_htlc_id=?"
msgstr ""
#: wallet/wallet.c:3941
#: wallet/wallet.c:3942
msgid "INSERT INTO forwarded_payments ( in_htlc_id, out_htlc_id, in_channel_scid, out_channel_scid, in_msatoshi, out_msatoshi, state, received_time, resolved_time, failcode) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"
msgstr ""
#: wallet/wallet.c:4000
#: wallet/wallet.c:4001
msgid "SELECT CAST(COALESCE(SUM(in_msatoshi - out_msatoshi), 0) AS BIGINT)FROM forwarded_payments WHERE state = ?;"
msgstr ""
#: wallet/wallet.c:4049
#: wallet/wallet.c:4050
msgid "SELECT f.state, in_msatoshi, out_msatoshi, hin.payment_hash as payment_hash, in_channel_scid, out_channel_scid, f.received_time, f.resolved_time, f.failcode FROM forwarded_payments f LEFT JOIN channel_htlcs hin ON (f.in_htlc_id = hin.id) WHERE (1 = ? OR f.state = ?) AND (1 = ? OR f.in_channel_scid = ?) AND (1 = ? OR f.out_channel_scid = ?)"
msgstr ""
#: wallet/wallet.c:4171
#: wallet/wallet.c:4172
msgid "SELECT t.id, t.rawtx, t.blockheight, t.txindex, t.type as txtype, c2.short_channel_id as txchan, a.location, a.idx as ann_idx, a.type as annotation_type, c.short_channel_id FROM transactions t LEFT JOIN transaction_annotations a ON (a.txid = t.id) LEFT JOIN channels c ON (a.channel = c.id) LEFT JOIN channels c2 ON (t.channel_id = c2.id) ORDER BY t.blockheight, t.txindex ASC"
msgstr ""
#: wallet/wallet.c:4265
#: wallet/wallet.c:4266
msgid "INSERT INTO penalty_bases ( channel_id, commitnum, txid, outnum, amount) VALUES (?, ?, ?, ?, ?);"
msgstr ""
#: wallet/wallet.c:4290
#: wallet/wallet.c:4291
msgid "SELECT commitnum, txid, outnum, amount FROM penalty_bases WHERE channel_id = ?"
msgstr ""
#: wallet/wallet.c:4314
#: wallet/wallet.c:4315
msgid "DELETE FROM penalty_bases WHERE channel_id = ? AND commitnum = ?"
msgstr ""
#: wallet/wallet.c:4332
#: wallet/wallet.c:4333
msgid "SELECT 1 FROM offers WHERE offer_id = ?;"
msgstr ""
#: wallet/wallet.c:4345
#: wallet/wallet.c:4346
msgid "INSERT INTO offers ( offer_id, bolt12, label, status) VALUES (?, ?, ?, ?);"
msgstr ""
#: wallet/wallet.c:4372
#: wallet/wallet.c:4373
msgid "SELECT bolt12, label, status FROM offers WHERE offer_id = ?;"
msgstr ""
#: wallet/wallet.c:4400
#: wallet/wallet.c:4401
msgid "SELECT offer_id FROM offers;"
msgstr ""
#: wallet/wallet.c:4426
#: wallet/wallet.c:4427
msgid "UPDATE offers SET status=? WHERE offer_id = ?;"
msgstr ""
#: wallet/wallet.c:4437
#: wallet/wallet.c:4438
msgid "UPDATE invoices SET state=? WHERE state=? AND local_offer_id = ?;"
msgstr ""
#: wallet/wallet.c:4465
#: wallet/wallet.c:4466
msgid "SELECT status FROM offers WHERE offer_id = ?;"
msgstr ""
@ -1257,4 +1257,4 @@ msgstr ""
#: wallet/test/run-wallet.c:1647
msgid "INSERT INTO channels (id) VALUES (1);"
msgstr ""
# SHA256STAMP:2fdded09bd28387ed024108cbe04c6ba1e158605c4c84eb1cf4caa83e26599fe
# SHA256STAMP:a6f2ee44515575973c58448f5859f557e748752253c9111de107991374fe5539

View file

@ -28,9 +28,6 @@
* to prune? */
#define UTXO_PRUNE_DEPTH 144
/* 12 hours is usually enough reservation time */
#define RESERVATION_INC (6 * 12)
static void outpointfilters_init(struct wallet *w)
{
struct db_stmt *stmt;
@ -439,7 +436,9 @@ static void db_set_utxo(struct db *db, const struct utxo *utxo)
db_exec_prepared_v2(take(stmt));
}
bool wallet_reserve_utxo(struct wallet *w, struct utxo *utxo, u32 current_height)
bool wallet_reserve_utxo(struct wallet *w, struct utxo *utxo,
u32 current_height,
u32 reserve)
{
switch (utxo->status) {
case OUTPUT_STATE_SPENT:
@ -453,9 +452,9 @@ bool wallet_reserve_utxo(struct wallet *w, struct utxo *utxo, u32 current_height
/* We simple increase existing reservations, which DTRT if we unreserve */
if (utxo->reserved_til >= current_height)
utxo->reserved_til += RESERVATION_INC;
utxo->reserved_til += reserve;
else
utxo->reserved_til = current_height + RESERVATION_INC;
utxo->reserved_til = current_height + reserve;
utxo->status = OUTPUT_STATE_RESERVED;
@ -464,18 +463,20 @@ bool wallet_reserve_utxo(struct wallet *w, struct utxo *utxo, u32 current_height
return true;
}
void wallet_unreserve_utxo(struct wallet *w, struct utxo *utxo, u32 current_height)
void wallet_unreserve_utxo(struct wallet *w, struct utxo *utxo,
u32 current_height,
u32 unreserve)
{
if (utxo->status != OUTPUT_STATE_RESERVED)
fatal("UTXO %s:%u is not reserved",
type_to_string(tmpctx, struct bitcoin_txid, &utxo->txid),
utxo->outnum);
if (utxo->reserved_til <= current_height + RESERVATION_INC) {
if (utxo->reserved_til <= current_height + unreserve) {
utxo->status = OUTPUT_STATE_AVAILABLE;
utxo->reserved_til = 0;
} else
utxo->reserved_til -= RESERVATION_INC;
utxo->reserved_til -= unreserve;
db_set_utxo(w->db, utxo);
}

View file

@ -405,19 +405,24 @@ bool wallet_add_onchaind_utxo(struct wallet *w,
/**
* wallet_reserve_utxo - set a reservation on a UTXO.
*
* If the reservation is already reserved, refreshes the reservation,
* otherwise if it's not available, returns false.
* If the reservation is already reserved:
* refreshes the reservation by @reserve, return true.
* Otherwise if it's available:
* reserves until @current_height + @reserve, returns true.
* Otherwise:
* returns false.
*/
bool wallet_reserve_utxo(struct wallet *w,
struct utxo *utxo,
u32 reservation_blocknum);
u32 current_height,
u32 reserve);
/* wallet_unreserve_utxo - make a reserved UTXO available again.
*
* Must be reserved.
*/
void wallet_unreserve_utxo(struct wallet *w, struct utxo *utxo,
u32 current_height);
u32 current_height, u32 unreserve);
/** wallet_utxo_get - Retrive a utxo.
*

View file

@ -756,6 +756,7 @@ struct sending_psbt {
struct command *cmd;
struct utxo **utxos;
struct wally_tx *wtx;
u32 reserve_blocks;
};
static void sendpsbt_done(struct bitcoind *bitcoind UNUSED,
@ -772,7 +773,8 @@ static void sendpsbt_done(struct bitcoind *bitcoind UNUSED,
for (size_t i = 0; i < tal_count(sending->utxos); i++) {
wallet_unreserve_utxo(ld->wallet,
sending->utxos[i],
get_block_height(ld->topology));
get_block_height(ld->topology),
sending->reserve_blocks);
}
was_pending(command_fail(sending->cmd, LIGHTNINGD,
@ -805,14 +807,17 @@ static struct command_result *json_sendpsbt(struct command *cmd,
struct sending_psbt *sending;
struct wally_psbt *psbt;
struct lightningd *ld = cmd->ld;
u32 *reserve_blocks;
if (!param(cmd, buffer, params,
p_req("psbt", param_psbt, &psbt),
p_opt_def("reserve", param_number, &reserve_blocks, 12 * 6),
NULL))
return command_param_failed();
sending = tal(cmd, struct sending_psbt);
sending->cmd = cmd;
sending->reserve_blocks = *reserve_blocks;
psbt_finalize(psbt);
sending->wtx = psbt_final_tx(sending, psbt);
@ -831,7 +836,8 @@ static struct command_result *json_sendpsbt(struct command *cmd,
for (size_t i = 0; i < tal_count(sending->utxos); i++) {
if (!wallet_reserve_utxo(ld->wallet, sending->utxos[i],
get_block_height(ld->topology)))
get_block_height(ld->topology),
sending->reserve_blocks))
fatal("UTXO not reservable?");
}