@@ -78,7 +78,7 @@ struct payment {
78
78
struct amount_msat maxfee ;
79
79
/* Maximum delay on the route we're ok with */
80
80
u32 maxdelay ;
81
- /* Maximum number of payment routes that can be pending. */
81
+ /* If non-zero: maximum number of payment routes that can be pending. */
82
82
u32 maxparts ;
83
83
/* Do we have to do it all in a single part? */
84
84
bool disable_mpp ;
@@ -172,7 +172,6 @@ static struct command_result *xpay_core(struct command *cmd,
172
172
u32 retryfor ,
173
173
const struct amount_msat * partial ,
174
174
u32 maxdelay ,
175
- u32 dev_maxparts ,
176
175
bool as_pay );
177
176
178
177
/* Wrapper for pending commands (ignores return) */
@@ -1287,6 +1286,16 @@ static struct command_result *getroutes_done_err(struct command *aux_cmd,
1287
1286
msg = json_strdup (tmpctx , buf , json_get_member (buf , error , "message" ));
1288
1287
json_to_int (buf , json_get_member (buf , error , "code" ), & code );
1289
1288
1289
+ /* If we were restricting the number of parts, we remove that
1290
+ * restriction and try again. */
1291
+ if (payment -> maxparts ) {
1292
+ payment_log (payment , LOG_INFORM ,
1293
+ "getroute failed with maxparts=%u, so retrying without that restriction" ,
1294
+ payment -> maxparts );
1295
+ payment -> maxparts = 0 ;
1296
+ return getroutes_for (aux_cmd , payment , payment -> amount_being_routed );
1297
+ }
1298
+
1290
1299
/* Simple case: failed immediately. */
1291
1300
if (payment -> total_num_attempts == 0 ) {
1292
1301
payment_give_up (aux_cmd , payment , code , "Failed: %s" , msg );
@@ -1319,7 +1328,6 @@ static struct command_result *getroutes_for(struct command *aux_cmd,
1319
1328
struct out_req * req ;
1320
1329
const struct pubkey * dst ;
1321
1330
struct amount_msat maxfee ;
1322
- size_t count_pending ;
1323
1331
1324
1332
/* I would normally assert here, but we have reports of this happening... */
1325
1333
if (amount_msat_is_zero (deliver )) {
@@ -1380,9 +1388,11 @@ static struct command_result *getroutes_for(struct command *aux_cmd,
1380
1388
json_add_amount_msat (req -> js , "maxfee_msat" , maxfee );
1381
1389
json_add_u32 (req -> js , "final_cltv" , payment -> final_cltv );
1382
1390
json_add_u32 (req -> js , "maxdelay" , payment -> maxdelay );
1383
- count_pending = count_current_attempts (payment );
1384
- assert (payment -> maxparts > count_pending );
1385
- json_add_u32 (req -> js , "maxparts" , payment -> maxparts - count_pending );
1391
+ if (payment -> maxparts ) {
1392
+ size_t count_pending = count_current_attempts (payment );
1393
+ assert (payment -> maxparts > count_pending );
1394
+ json_add_u32 (req -> js , "maxparts" , payment -> maxparts - count_pending );
1395
+ }
1386
1396
1387
1397
return send_payment_req (aux_cmd , payment , req );
1388
1398
}
@@ -1693,7 +1703,7 @@ struct xpay_params {
1693
1703
struct amount_msat * msat , * maxfee , * partial ;
1694
1704
const char * * layers ;
1695
1705
unsigned int retryfor ;
1696
- u32 maxdelay , dev_maxparts ;
1706
+ u32 maxdelay ;
1697
1707
const char * bip353 ;
1698
1708
};
1699
1709
@@ -1710,7 +1720,7 @@ invoice_fetched(struct command *cmd,
1710
1720
return xpay_core (cmd , take (to_canonical_invstr (NULL , take (inv ))),
1711
1721
NULL , params -> maxfee , params -> layers ,
1712
1722
params -> retryfor , params -> partial , params -> maxdelay ,
1713
- params -> dev_maxparts , false);
1723
+ false);
1714
1724
}
1715
1725
1716
1726
static struct command_result *
@@ -1771,7 +1781,7 @@ static struct command_result *json_xpay_params(struct command *cmd,
1771
1781
struct amount_msat * msat , * maxfee , * partial ;
1772
1782
const char * invstring ;
1773
1783
const char * * layers ;
1774
- u32 * maxdelay , * maxparts ;
1784
+ u32 * maxdelay ;
1775
1785
unsigned int * retryfor ;
1776
1786
struct out_req * req ;
1777
1787
struct xpay_params * xparams ;
@@ -1784,14 +1794,9 @@ static struct command_result *json_xpay_params(struct command *cmd,
1784
1794
p_opt_def ("retry_for" , param_number , & retryfor , 60 ),
1785
1795
p_opt ("partial_msat" , param_msat , & partial ),
1786
1796
p_opt_def ("maxdelay" , param_u32 , & maxdelay , 2016 ),
1787
- p_opt_dev ("dev_maxparts" , param_u32 , & maxparts , 100 ),
1788
1797
NULL ))
1789
1798
return command_param_failed ();
1790
1799
1791
- if (* maxparts == 0 )
1792
- return command_fail (cmd , JSONRPC2_INVALID_PARAMS ,
1793
- "maxparts cannot be zero" );
1794
-
1795
1800
/* Is this a one-shot vibe payment? Kids these days! */
1796
1801
if (!as_pay && bolt12_has_offer_prefix (invstring )) {
1797
1802
struct command_result * ret ;
@@ -1810,7 +1815,6 @@ static struct command_result *json_xpay_params(struct command *cmd,
1810
1815
xparams -> layers = layers ;
1811
1816
xparams -> retryfor = * retryfor ;
1812
1817
xparams -> maxdelay = * maxdelay ;
1813
- xparams -> dev_maxparts = * maxparts ;
1814
1818
xparams -> bip353 = NULL ;
1815
1819
1816
1820
return do_fetchinvoice (cmd , invstring , xparams );
@@ -1825,7 +1829,6 @@ static struct command_result *json_xpay_params(struct command *cmd,
1825
1829
xparams -> layers = layers ;
1826
1830
xparams -> retryfor = * retryfor ;
1827
1831
xparams -> maxdelay = * maxdelay ;
1828
- xparams -> dev_maxparts = * maxparts ;
1829
1832
xparams -> bip353 = invstring ;
1830
1833
1831
1834
req = jsonrpc_request_start (cmd , "fetchbip353" ,
@@ -1836,7 +1839,7 @@ static struct command_result *json_xpay_params(struct command *cmd,
1836
1839
}
1837
1840
1838
1841
return xpay_core (cmd , invstring ,
1839
- msat , maxfee , layers , * retryfor , partial , * maxdelay , * maxparts ,
1842
+ msat , maxfee , layers , * retryfor , partial , * maxdelay ,
1840
1843
as_pay );
1841
1844
}
1842
1845
@@ -1848,11 +1851,12 @@ static struct command_result *xpay_core(struct command *cmd,
1848
1851
u32 retryfor ,
1849
1852
const struct amount_msat * partial ,
1850
1853
u32 maxdelay ,
1851
- u32 dev_maxparts ,
1852
1854
bool as_pay )
1853
1855
{
1854
1856
struct payment * payment = tal (cmd , struct payment );
1855
1857
struct xpay * xpay = xpay_of (cmd -> plugin );
1858
+ struct gossmap * gossmap = get_gossmap (xpay );
1859
+ struct node_id dstid ;
1856
1860
u64 now , invexpiry ;
1857
1861
struct out_req * req ;
1858
1862
char * err ;
@@ -1875,10 +1879,8 @@ static struct command_result *xpay_core(struct command *cmd,
1875
1879
else
1876
1880
payment -> layers = NULL ;
1877
1881
payment -> maxdelay = maxdelay ;
1878
- payment -> maxparts = dev_maxparts ;
1879
1882
1880
1883
if (bolt12_has_prefix (payment -> invstring )) {
1881
- struct gossmap * gossmap = get_gossmap (xpay );
1882
1884
struct tlv_invoice * b12inv
1883
1885
= invoice_decode (tmpctx , payment -> invstring ,
1884
1886
strlen (payment -> invstring ),
@@ -2004,6 +2006,15 @@ static struct command_result *xpay_core(struct command *cmd,
2004
2006
} else
2005
2007
payment -> maxfee = * maxfee ;
2006
2008
2009
+ /* If we are using an unannounced channel, we assume we can
2010
+ * only do 6 HTLCs at a time. This is currently true for
2011
+ * Phoenix, which is a large and significant node. */
2012
+ node_id_from_pubkey (& dstid , & payment -> destination );
2013
+ if (!gossmap_find_node (gossmap , & dstid ))
2014
+ payment -> maxparts = 6 ;
2015
+ else
2016
+ payment -> maxparts = 0 ;
2017
+
2007
2018
/* Now preapprove, then start payment. */
2008
2019
if (command_check_only (cmd )) {
2009
2020
req = jsonrpc_request_start (cmd , "check" ,
0 commit comments