Skip to content

Commit 9d05ba6

Browse files
authored
Merge branch 'master' into feature/xpay-payment-description
2 parents c15a836 + 98a188b commit 9d05ba6

File tree

9 files changed

+33
-14
lines changed

9 files changed

+33
-14
lines changed

cln-grpc/proto/node.proto

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-grpc/src/convert.rs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-rpc/src/model.rs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/msggen/msggen/schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24159,6 +24159,12 @@
2415924159
"The short_channel_id (once locked in)."
2416024160
]
2416124161
},
24162+
"direction": {
24163+
"type": "integer",
24164+
"description": [
24165+
"The direction of the channel (i.e. 0 if we are the lesser node id, 1 if we are the greater)."
24166+
]
24167+
},
2416224168
"channel_id": {
2416324169
"type": "hash",
2416424170
"description": [

doc/schemas/listpeerchannels.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,12 @@
311311
"The short_channel_id (once locked in)."
312312
]
313313
},
314+
"direction": {
315+
"type": "integer",
316+
"description": [
317+
"The direction of the channel (i.e. 0 if we are the lesser node id, 1 if we are the greater)."
318+
]
319+
},
314320
"channel_id": {
315321
"type": "hash",
316322
"description": [

lightningd/chaintopology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ void setup_topology(struct chain_topology *topo)
14201420
fixup = db_get_intvar(topo->ld->wallet->db, "fixup_block_scan", -1);
14211421
if (fixup == -1) {
14221422
/* Never done fixup: this is set to non-zero if we have blocks. */
1423-
topo->old_block_scan = wallet_blocks_minheight(topo->ld->wallet);
1423+
topo->old_block_scan = wallet_blocks_contig_minheight(topo->ld->wallet);
14241424
db_set_intvar(topo->ld->wallet->db, "fixup_block_scan",
14251425
topo->old_block_scan);
14261426
} else {

tests/test_plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3613,6 +3613,8 @@ def test_sql(node_factory, bitcoind):
36133613
'type': 'string'},
36143614
{'name': 'short_channel_id',
36153615
'type': 'short_channel_id'},
3616+
{'name': 'direction',
3617+
'type': 'u32'},
36163618
{'name': 'channel_id',
36173619
'type': 'hash'},
36183620
{'name': 'funding_txid',
@@ -3715,9 +3717,7 @@ def test_sql(node_factory, bitcoind):
37153717
{'name': 'close_to_addr',
37163718
'type': 'string'},
37173719
{'name': 'last_tx_fee_msat',
3718-
'type': 'msat'},
3719-
{'name': 'direction',
3720-
'type': 'u32'}]},
3720+
'type': 'msat'}]},
37213721
'peerchannels_features': {
37223722
'columns': [{'name': 'row',
37233723
'type': 'u64'},

wallet/wallet.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2554,16 +2554,22 @@ u32 wallet_blocks_maxheight(struct wallet *w)
25542554
return max;
25552555
}
25562556

2557-
u32 wallet_blocks_minheight(struct wallet *w)
2557+
u32 wallet_blocks_contig_minheight(struct wallet *w)
25582558
{
25592559
u32 min = 0;
2560-
struct db_stmt *stmt = db_prepare_v2(w->db, SQL("SELECT MIN(height) FROM blocks;"));
2560+
struct db_stmt *stmt = db_prepare_v2(w->db, SQL("SELECT MAX(b.height)"
2561+
" FROM blocks b"
2562+
" WHERE NOT EXISTS ("
2563+
" SELECT 1"
2564+
" FROM blocks b2"
2565+
" WHERE b2.height = b.height - 1)"));
25612566
db_query_prepared(stmt);
25622567

2563-
/* If we ever processed a block we'll get the latest block in the chain */
2568+
/* If we ever processed a block we'll get the first block in
2569+
* the last run of blocks */
25642570
if (db_step(stmt)) {
2565-
if (!db_col_is_null(stmt, "MIN(height)")) {
2566-
min = db_col_int(stmt, "MIN(height)");
2571+
if (!db_col_is_null(stmt, "MAX(b.height)")) {
2572+
min = db_col_int(stmt, "MAX(b.height)");
25672573
}
25682574
}
25692575
tal_free(stmt);

wallet/wallet.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,13 +790,14 @@ void wallet_channel_stats_incr_out_fulfilled(struct wallet *w, u64 cdbid, struct
790790
u32 wallet_blocks_maxheight(struct wallet *w);
791791

792792
/**
793-
* Retrieve the blockheight of the first block processed by lightningd.
793+
* Retrieve the blockheight of the first block processed by lightningd (ignoring
794+
* backfilled blocks for gossip).
794795
*
795796
* Will return the 0 if the wallet was never used before.
796797
*
797798
* @w: wallet to load from.
798799
*/
799-
u32 wallet_blocks_minheight(struct wallet *w);
800+
u32 wallet_blocks_contig_minheight(struct wallet *w);
800801

801802
/**
802803
* wallet_extract_owned_outputs - given a tx, extract all of our outputs

0 commit comments

Comments
 (0)