lightningd: change msatoshi args to amount_msat.

This is consistent with our output changes, and increases consistency.
It also keeps future sanity checks happy, that we only use JSON msat
helpers with '_msat' fields.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: JSON-RPC: `invoice`, `sendonion`, `sendpay`, `pay`, `keysend`, `fetchinvoice`, `sendinvoice`: `msatoshi` argument is now called `amount_msat` to match other fields.
Changelog-Deprecated: JSON-RPC: `invoice`, `sendonion`, `sendpay`, `pay`, `keysend`, `fetchinvoice`, `sendinvoice` `msatoshi` (use `amount_msat`)
This commit is contained in:
Rusty Russell
2022-06-19 16:50:11 +09:30
parent ca69e293d1
commit cd7e784d6f
25 changed files with 192 additions and 154 deletions

View File

@@ -443,6 +443,7 @@
"Getinfo.warning_lightningd_sync": 17 "Getinfo.warning_lightningd_sync": 17
}, },
"GetrouteRequest": { "GetrouteRequest": {
"GetRoute.amount_msat": 9,
"GetRoute.cltv": 4, "GetRoute.cltv": 4,
"GetRoute.exclude[]": 7, "GetRoute.exclude[]": 7,
"GetRoute.fromid": 5, "GetRoute.fromid": 5,
@@ -464,6 +465,7 @@
"GetRoute.route[].style": 6 "GetRoute.route[].style": 6
}, },
"InvoiceRequest": { "InvoiceRequest": {
"Invoice.amount_msat": 10,
"Invoice.cltv": 6, "Invoice.cltv": 6,
"Invoice.deschashonly": 9, "Invoice.deschashonly": 9,
"Invoice.description": 2, "Invoice.description": 2,
@@ -486,6 +488,7 @@
"Invoice.warning_private_unused": 8 "Invoice.warning_private_unused": 8
}, },
"KeysendRequest": { "KeysendRequest": {
"KeySend.amount_msat": 10,
"KeySend.destination": 1, "KeySend.destination": 1,
"KeySend.exemptfee": 7, "KeySend.exemptfee": 7,
"KeySend.extratlvs": 9, "KeySend.extratlvs": 9,
@@ -821,6 +824,7 @@
"NewAddr.p2sh-segwit": 2 "NewAddr.p2sh-segwit": 2
}, },
"PayRequest": { "PayRequest": {
"Pay.amount_msat": 13,
"Pay.bolt11": 1, "Pay.bolt11": 1,
"Pay.description": 12, "Pay.description": 12,
"Pay.exclude": 10, "Pay.exclude": 10,
@@ -859,6 +863,7 @@
"SendOnion.first_hop.id": 1 "SendOnion.first_hop.id": 1
}, },
"SendonionRequest": { "SendonionRequest": {
"SendOnion.amount_msat": 12,
"SendOnion.bolt11": 7, "SendOnion.bolt11": 7,
"SendOnion.destination": 9, "SendOnion.destination": 9,
"SendOnion.first_hop": 2, "SendOnion.first_hop": 2,
@@ -887,6 +892,7 @@
"SendOnion.status": 3 "SendOnion.status": 3
}, },
"SendpayRequest": { "SendpayRequest": {
"SendPay.amount_msat": 10,
"SendPay.bolt11": 5, "SendPay.bolt11": 5,
"SendPay.groupid": 9, "SendPay.groupid": 9,
"SendPay.label": 3, "SendPay.label": 3,
@@ -914,6 +920,7 @@
"SendPay.status": 4 "SendPay.status": 4
}, },
"SendpayRoute": { "SendpayRoute": {
"SendPay.route[].amount_msat": 5,
"SendPay.route[].channel": 4, "SendPay.route[].channel": 4,
"SendPay.route[].delay": 3, "SendPay.route[].delay": 3,
"SendPay.route[].id": 2, "SendPay.route[].id": 2,

View File

@@ -291,7 +291,7 @@ message SendpayRequest {
repeated SendpayRoute route = 1; repeated SendpayRoute route = 1;
bytes payment_hash = 2; bytes payment_hash = 2;
optional string label = 3; optional string label = 3;
optional Amount msatoshi = 4; optional Amount amount_msat = 10;
optional string bolt11 = 5; optional string bolt11 = 5;
optional bytes payment_secret = 6; optional bytes payment_secret = 6;
optional uint32 partid = 7; optional uint32 partid = 7;
@@ -322,7 +322,7 @@ message SendpayResponse {
} }
message SendpayRoute { message SendpayRoute {
Amount msatoshi = 1; optional Amount amount_msat = 5;
bytes id = 2; bytes id = 2;
uint32 delay = 3; uint32 delay = 3;
string channel = 4; string channel = 4;
@@ -559,7 +559,7 @@ message DelinvoiceResponse {
} }
message InvoiceRequest { message InvoiceRequest {
AmountOrAny msatoshi = 1; AmountOrAny amount_msat = 10;
string description = 2; string description = 2;
string label = 3; string label = 3;
optional uint64 expiry = 7; optional uint64 expiry = 7;
@@ -638,7 +638,7 @@ message SendonionRequest {
repeated bytes shared_secrets = 5; repeated bytes shared_secrets = 5;
optional uint32 partid = 6; optional uint32 partid = 6;
optional string bolt11 = 7; optional string bolt11 = 7;
optional Amount msatoshi = 8; optional Amount amount_msat = 12;
optional bytes destination = 9; optional bytes destination = 9;
optional bytes localofferid = 10; optional bytes localofferid = 10;
optional uint64 groupid = 11; optional uint64 groupid = 11;
@@ -775,7 +775,7 @@ message ListtransactionsTransactionsOutputs {
message PayRequest { message PayRequest {
string bolt11 = 1; string bolt11 = 1;
optional Amount msatoshi = 2; optional Amount amount_msat = 13;
optional string label = 3; optional string label = 3;
optional double riskfactor = 8; optional double riskfactor = 8;
optional double maxfeepercent = 4; optional double maxfeepercent = 4;
@@ -945,7 +945,7 @@ message WithdrawResponse {
message KeysendRequest { message KeysendRequest {
bytes destination = 1; bytes destination = 1;
Amount msatoshi = 2; Amount amount_msat = 10;
optional string label = 3; optional string label = 3;
optional double maxfeepercent = 4; optional double maxfeepercent = 4;
optional uint32 retry_for = 5; optional uint32 retry_for = 5;
@@ -1134,7 +1134,7 @@ message FeeratesOnchain_fee_estimates {
message GetrouteRequest { message GetrouteRequest {
bytes id = 1; bytes id = 1;
Amount msatoshi = 2; Amount amount_msat = 9;
uint64 riskfactor = 3; uint64 riskfactor = 3;
optional double cltv = 4; optional double cltv = 4;
optional bytes fromid = 5; optional bytes fromid = 5;

View File

@@ -980,7 +980,7 @@ impl From<&pb::ListfundsRequest> for requests::ListfundsRequest {
impl From<&pb::SendpayRoute> for requests::SendpayRoute { impl From<&pb::SendpayRoute> for requests::SendpayRoute {
fn from(c: &pb::SendpayRoute) -> Self { fn from(c: &pb::SendpayRoute) -> Self {
Self { Self {
msatoshi: c.msatoshi.as_ref().unwrap().into(), // Rule #1 for type msat amount_msat: c.amount_msat.as_ref().map(|a| a.into()), // Rule #1 for type msat?
id: cln_rpc::primitives::Pubkey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey id: cln_rpc::primitives::Pubkey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey
delay: c.delay as u16, // Rule #1 for type u16 delay: c.delay as u16, // Rule #1 for type u16
channel: cln_rpc::primitives::ShortChannelId::from_str(&c.channel).unwrap(), // Rule #1 for type short_channel_id channel: cln_rpc::primitives::ShortChannelId::from_str(&c.channel).unwrap(), // Rule #1 for type short_channel_id
@@ -995,7 +995,7 @@ impl From<&pb::SendpayRequest> for requests::SendpayRequest {
route: c.route.iter().map(|s| s.into()).collect(), // Rule #4 route: c.route.iter().map(|s| s.into()).collect(), // Rule #4
payment_hash: c.payment_hash.clone().try_into().unwrap(), // Rule #1 for type hash payment_hash: c.payment_hash.clone().try_into().unwrap(), // Rule #1 for type hash
label: c.label.clone(), // Rule #1 for type string? label: c.label.clone(), // Rule #1 for type string?
msatoshi: c.msatoshi.as_ref().map(|a| a.into()), // Rule #1 for type msat? amount_msat: c.amount_msat.as_ref().map(|a| a.into()), // Rule #1 for type msat?
bolt11: c.bolt11.clone(), // Rule #1 for type string? bolt11: c.bolt11.clone(), // Rule #1 for type string?
payment_secret: c.payment_secret.clone().map(|v| v.try_into().unwrap()), // Rule #1 for type secret? payment_secret: c.payment_secret.clone().map(|v| v.try_into().unwrap()), // Rule #1 for type secret?
partid: c.partid.map(|v| v as u16), // Rule #1 for type u16? partid: c.partid.map(|v| v as u16), // Rule #1 for type u16?
@@ -1152,7 +1152,7 @@ impl From<&pb::DelinvoiceRequest> for requests::DelinvoiceRequest {
impl From<&pb::InvoiceRequest> for requests::InvoiceRequest { impl From<&pb::InvoiceRequest> for requests::InvoiceRequest {
fn from(c: &pb::InvoiceRequest) -> Self { fn from(c: &pb::InvoiceRequest) -> Self {
Self { Self {
msatoshi: c.msatoshi.as_ref().unwrap().into(), // Rule #1 for type msat_or_any amount_msat: c.amount_msat.as_ref().unwrap().into(), // Rule #1 for type msat_or_any
description: c.description.clone(), // Rule #1 for type string description: c.description.clone(), // Rule #1 for type string
label: c.label.clone(), // Rule #1 for type string label: c.label.clone(), // Rule #1 for type string
expiry: c.expiry.clone(), // Rule #1 for type u64? expiry: c.expiry.clone(), // Rule #1 for type u64?
@@ -1196,7 +1196,7 @@ impl From<&pb::SendonionRequest> for requests::SendonionRequest {
shared_secrets: Some(c.shared_secrets.iter().map(|s| s.clone().try_into().unwrap()).collect()), // Rule #4 shared_secrets: Some(c.shared_secrets.iter().map(|s| s.clone().try_into().unwrap()).collect()), // Rule #4
partid: c.partid.map(|v| v as u16), // Rule #1 for type u16? partid: c.partid.map(|v| v as u16), // Rule #1 for type u16?
bolt11: c.bolt11.clone(), // Rule #1 for type string? bolt11: c.bolt11.clone(), // Rule #1 for type string?
msatoshi: c.msatoshi.as_ref().map(|a| a.into()), // Rule #1 for type msat? amount_msat: c.amount_msat.as_ref().map(|a| a.into()), // Rule #1 for type msat?
destination: c.destination.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey? destination: c.destination.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey?
localofferid: c.localofferid.clone().map(|v| v.try_into().unwrap()), // Rule #1 for type hash? localofferid: c.localofferid.clone().map(|v| v.try_into().unwrap()), // Rule #1 for type hash?
groupid: c.groupid.clone(), // Rule #1 for type u64? groupid: c.groupid.clone(), // Rule #1 for type u64?
@@ -1228,7 +1228,7 @@ impl From<&pb::PayRequest> for requests::PayRequest {
fn from(c: &pb::PayRequest) -> Self { fn from(c: &pb::PayRequest) -> Self {
Self { Self {
bolt11: c.bolt11.clone(), // Rule #1 for type string bolt11: c.bolt11.clone(), // Rule #1 for type string
msatoshi: c.msatoshi.as_ref().map(|a| a.into()), // Rule #1 for type msat? amount_msat: c.amount_msat.as_ref().map(|a| a.into()), // Rule #1 for type msat?
label: c.label.clone(), // Rule #1 for type string? label: c.label.clone(), // Rule #1 for type string?
riskfactor: c.riskfactor.clone(), // Rule #1 for type number? riskfactor: c.riskfactor.clone(), // Rule #1 for type number?
maxfeepercent: c.maxfeepercent.clone(), // Rule #1 for type number? maxfeepercent: c.maxfeepercent.clone(), // Rule #1 for type number?
@@ -1310,7 +1310,7 @@ impl From<&pb::KeysendRequest> for requests::KeysendRequest {
fn from(c: &pb::KeysendRequest) -> Self { fn from(c: &pb::KeysendRequest) -> Self {
Self { Self {
destination: cln_rpc::primitives::Pubkey::from_slice(&c.destination).unwrap(), // Rule #1 for type pubkey destination: cln_rpc::primitives::Pubkey::from_slice(&c.destination).unwrap(), // Rule #1 for type pubkey
msatoshi: c.msatoshi.as_ref().unwrap().into(), // Rule #1 for type msat amount_msat: c.amount_msat.as_ref().unwrap().into(), // Rule #1 for type msat
label: c.label.clone(), // Rule #1 for type string? label: c.label.clone(), // Rule #1 for type string?
maxfeepercent: c.maxfeepercent.clone(), // Rule #1 for type number? maxfeepercent: c.maxfeepercent.clone(), // Rule #1 for type number?
retry_for: c.retry_for.clone(), // Rule #1 for type u32? retry_for: c.retry_for.clone(), // Rule #1 for type u32?
@@ -1428,7 +1428,7 @@ impl From<&pb::GetrouteRequest> for requests::GetrouteRequest {
fn from(c: &pb::GetrouteRequest) -> Self { fn from(c: &pb::GetrouteRequest) -> Self {
Self { Self {
id: cln_rpc::primitives::Pubkey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey id: cln_rpc::primitives::Pubkey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey
msatoshi: c.msatoshi.as_ref().unwrap().into(), // Rule #1 for type msat amount_msat: c.amount_msat.as_ref().unwrap().into(), // Rule #1 for type msat
riskfactor: c.riskfactor.clone(), // Rule #1 for type u64 riskfactor: c.riskfactor.clone(), // Rule #1 for type u64
cltv: c.cltv.clone(), // Rule #1 for type number? cltv: c.cltv.clone(), // Rule #1 for type number?
fromid: c.fromid.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey? fromid: c.fromid.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey?

View File

@@ -138,8 +138,8 @@ pub mod requests {
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SendpayRoute { pub struct SendpayRoute {
#[serde(alias = "msatoshi")] #[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")]
pub msatoshi: Amount, pub amount_msat: Option<Amount>,
#[serde(alias = "id")] #[serde(alias = "id")]
pub id: Pubkey, pub id: Pubkey,
#[serde(alias = "delay")] #[serde(alias = "delay")]
@@ -156,8 +156,8 @@ pub mod requests {
pub payment_hash: Sha256, pub payment_hash: Sha256,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")] #[serde(alias = "label", skip_serializing_if = "Option::is_none")]
pub label: Option<String>, pub label: Option<String>,
#[serde(alias = "msatoshi", skip_serializing_if = "Option::is_none")] #[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")]
pub msatoshi: Option<Amount>, pub amount_msat: Option<Amount>,
#[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")] #[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")]
pub bolt11: Option<String>, pub bolt11: Option<String>,
#[serde(alias = "payment_secret", skip_serializing_if = "Option::is_none")] #[serde(alias = "payment_secret", skip_serializing_if = "Option::is_none")]
@@ -351,8 +351,8 @@ pub mod requests {
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct InvoiceRequest { pub struct InvoiceRequest {
#[serde(alias = "msatoshi")] #[serde(alias = "amount_msat")]
pub msatoshi: AmountOrAny, pub amount_msat: AmountOrAny,
#[serde(alias = "description")] #[serde(alias = "description")]
pub description: String, pub description: String,
#[serde(alias = "label")] #[serde(alias = "label")]
@@ -413,8 +413,8 @@ pub mod requests {
pub partid: Option<u16>, pub partid: Option<u16>,
#[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")] #[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")]
pub bolt11: Option<String>, pub bolt11: Option<String>,
#[serde(alias = "msatoshi", skip_serializing_if = "Option::is_none")] #[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")]
pub msatoshi: Option<Amount>, pub amount_msat: Option<Amount>,
#[serde(alias = "destination", skip_serializing_if = "Option::is_none")] #[serde(alias = "destination", skip_serializing_if = "Option::is_none")]
pub destination: Option<Pubkey>, pub destination: Option<Pubkey>,
#[serde(alias = "localofferid", skip_serializing_if = "Option::is_none")] #[serde(alias = "localofferid", skip_serializing_if = "Option::is_none")]
@@ -462,8 +462,8 @@ pub mod requests {
pub struct PayRequest { pub struct PayRequest {
#[serde(alias = "bolt11")] #[serde(alias = "bolt11")]
pub bolt11: String, pub bolt11: String,
#[serde(alias = "msatoshi", skip_serializing_if = "Option::is_none")] #[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")]
pub msatoshi: Option<Amount>, pub amount_msat: Option<Amount>,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")] #[serde(alias = "label", skip_serializing_if = "Option::is_none")]
pub label: Option<String>, pub label: Option<String>,
#[serde(alias = "riskfactor", skip_serializing_if = "Option::is_none")] #[serde(alias = "riskfactor", skip_serializing_if = "Option::is_none")]
@@ -567,8 +567,8 @@ pub mod requests {
pub struct KeysendRequest { pub struct KeysendRequest {
#[serde(alias = "destination")] #[serde(alias = "destination")]
pub destination: Pubkey, pub destination: Pubkey,
#[serde(alias = "msatoshi")] #[serde(alias = "amount_msat")]
pub msatoshi: Amount, pub amount_msat: Amount,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")] #[serde(alias = "label", skip_serializing_if = "Option::is_none")]
pub label: Option<String>, pub label: Option<String>,
#[serde(alias = "maxfeepercent", skip_serializing_if = "Option::is_none")] #[serde(alias = "maxfeepercent", skip_serializing_if = "Option::is_none")]
@@ -702,8 +702,8 @@ pub mod requests {
pub struct GetrouteRequest { pub struct GetrouteRequest {
#[serde(alias = "id")] #[serde(alias = "id")]
pub id: Pubkey, pub id: Pubkey,
#[serde(alias = "msatoshi")] #[serde(alias = "amount_msat")]
pub msatoshi: Amount, pub amount_msat: Amount,
#[serde(alias = "riskfactor")] #[serde(alias = "riskfactor")]
pub riskfactor: u64, pub riskfactor: u64,
#[serde(alias = "cltv", skip_serializing_if = "Option::is_none")] #[serde(alias = "cltv", skip_serializing_if = "Option::is_none")]

View File

@@ -615,7 +615,7 @@ class LightningRpc(UnixDomainSocketRpc):
""" """
return self.call("dev-memleak") return self.call("dev-memleak")
def dev_pay(self, bolt11, msatoshi=None, label=None, riskfactor=None, def dev_pay(self, bolt11, amount_msat=None, label=None, riskfactor=None,
maxfeepercent=None, retry_for=None, maxfeepercent=None, retry_for=None,
maxdelay=None, exemptfee=None, use_shadow=True, exclude=None): maxdelay=None, exemptfee=None, use_shadow=True, exclude=None):
""" """
@@ -624,7 +624,7 @@ class LightningRpc(UnixDomainSocketRpc):
""" """
payload = { payload = {
"bolt11": bolt11, "bolt11": bolt11,
"msatoshi": msatoshi, "amount_msat": amount_msat,
"label": label, "label": label,
"riskfactor": riskfactor, "riskfactor": riskfactor,
"maxfeepercent": maxfeepercent, "maxfeepercent": maxfeepercent,
@@ -797,19 +797,26 @@ class LightningRpc(UnixDomainSocketRpc):
res = self.call("listpeers", payload) res = self.call("listpeers", payload)
return res.get("peers") and res["peers"][0] or None return res.get("peers") and res["peers"][0] or None
def getroute(self, node_id, msatoshi, riskfactor, cltv=9, fromid=None, def getroute(self, node_id, amount_msat=None, riskfactor=None, cltv=9, fromid=None,
fuzzpercent=None, exclude=None, maxhops=None): fuzzpercent=None, exclude=None, maxhops=None, msatoshi=None):
""" """
Show route to {id} for {msatoshi}, using {riskfactor} and optional Show route to {id} for {amount_msat}, using {riskfactor} and optional
{cltv} (default 9). If specified search from {fromid} otherwise use {cltv} (default 9). If specified search from {fromid} otherwise use
this node as source. Randomize the route with up to {fuzzpercent} this node as source. Randomize the route with up to {fuzzpercent}
(0.0 -> 100.0, default 5.0). {exclude} is an optional array of (0.0 -> 100.0, default 5.0). {exclude} is an optional array of
scid/direction or node-id to exclude. Limit the number of hops in the scid/direction or node-id to exclude. Limit the number of hops in the
route to {maxhops}. route to {maxhops}.
""" """
if msatoshi:
amount_msat = msatoshi
if riskfactor is None:
raise TypeError("getroute() missing 'riskfactor'")
if amount_msat is None:
raise TypeError("getroute() missing 'amount_msat'")
payload = { payload = {
"id": node_id, "id": node_id,
"msatoshi": msatoshi, "amount_msat": amount_msat,
"riskfactor": riskfactor, "riskfactor": riskfactor,
"cltv": cltv, "cltv": cltv,
"fromid": fromid, "fromid": fromid,
@@ -828,14 +835,22 @@ class LightningRpc(UnixDomainSocketRpc):
} }
return self.call("help", payload) return self.call("help", payload)
def invoice(self, msatoshi, label, description, expiry=None, fallbacks=None, def invoice(self, amount_msat=None, label=None, description=None, expiry=None, fallbacks=None,
preimage=None, exposeprivatechannels=None, cltv=None, deschashonly=None): preimage=None, exposeprivatechannels=None, cltv=None, deschashonly=None, msatoshi=None):
""" """
Create an invoice for {msatoshi} with {label} and {description} with Create an invoice for {amount_msat} with {label} and {description} with
optional {expiry} seconds (default 1 week). optional {expiry} seconds (default 1 week).
""" """
if msatoshi:
amount_msat = msatoshi
if label is None:
raise TypeError("invoice() missing 'label'")
if description is None:
raise TypeError("invoice() missing 'description'")
if amount_msat is None:
raise TypeError("invoice() missing 'amount_msat'")
payload = { payload = {
"msatoshi": msatoshi, "amount_msat": amount_msat,
"label": label, "label": label,
"description": description, "description": description,
"expiry": expiry, "expiry": expiry,
@@ -995,18 +1010,21 @@ class LightningRpc(UnixDomainSocketRpc):
""" """
return self.call("newaddr", {"addresstype": addresstype}) return self.call("newaddr", {"addresstype": addresstype})
def pay(self, bolt11, msatoshi=None, label=None, riskfactor=None, def pay(self, bolt11, amount_msat=None, label=None, riskfactor=None,
maxfeepercent=None, retry_for=None, maxfeepercent=None, retry_for=None,
maxdelay=None, exemptfee=None, localofferid=None, exclude=None, maxdelay=None, exemptfee=None, localofferid=None, exclude=None,
maxfee=None, description=None): maxfee=None, description=None, msatoshi=None):
""" """
Send payment specified by {bolt11} with {msatoshi} Send payment specified by {bolt11} with {amount_msat}
(ignored if {bolt11} has an amount), optional {label} (ignored if {bolt11} has an amount), optional {label}
and {riskfactor} (default 1.0). and {riskfactor} (default 1.0).
""" """
# Deprecated usage
if msatoshi:
amount_msat = msatoshi
payload = { payload = {
"bolt11": bolt11, "bolt11": bolt11,
"msatoshi": msatoshi, "amount_msat": amount_msat,
"label": label, "label": label,
"riskfactor": riskfactor, "riskfactor": riskfactor,
"maxfeepercent": maxfeepercent, "maxfeepercent": maxfeepercent,
@@ -1132,15 +1150,18 @@ class LightningRpc(UnixDomainSocketRpc):
} }
return self.call("plugin", payload) return self.call("plugin", payload)
def sendpay(self, route, payment_hash, label=None, msatoshi=None, bolt11=None, payment_secret=None, partid=None, groupid=None, payment_metadata=None): def sendpay(self, route, payment_hash, label=None, amount_msat=None, bolt11=None, payment_secret=None, partid=None, groupid=None, payment_metadata=None, msatoshi=None):
""" """
Send along {route} in return for preimage of {payment_hash}. Send along {route} in return for preimage of {payment_hash}.
""" """
# Deprecated usage
if msatoshi:
amount_msat = msatoshi
payload = { payload = {
"route": route, "route": route,
"payment_hash": payment_hash, "payment_hash": payment_hash,
"label": label, "label": label,
"msatoshi": msatoshi, "amount_msat": amount_msat,
"bolt11": bolt11, "bolt11": bolt11,
"payment_secret": payment_secret, "payment_secret": payment_secret,
"partid": partid, "partid": partid,
@@ -1151,8 +1172,8 @@ class LightningRpc(UnixDomainSocketRpc):
def sendonion( def sendonion(
self, onion, first_hop, payment_hash, label=None, self, onion, first_hop, payment_hash, label=None,
shared_secrets=None, partid=None, bolt11=None, msatoshi=None, shared_secrets=None, partid=None, bolt11=None, amount_msat=None,
destination=None destination=None, msatoshi=None
): ):
"""Send an outgoing payment using the specified onion. """Send an outgoing payment using the specified onion.
@@ -1161,6 +1182,9 @@ class LightningRpc(UnixDomainSocketRpc):
internal handling, but not required. internal handling, but not required.
""" """
# Deprecated usage
if msatoshi:
amount_msat = msatoshi
payload = { payload = {
"onion": onion, "onion": onion,
"first_hop": first_hop, "first_hop": first_hop,
@@ -1169,7 +1193,7 @@ class LightningRpc(UnixDomainSocketRpc):
"shared_secrets": shared_secrets, "shared_secrets": shared_secrets,
"partid": partid, "partid": partid,
"bolt11": bolt11, "bolt11": bolt11,
"msatoshi": msatoshi, "amount_msat": amount_msat,
"destination": destination, "destination": destination,
} }
return self.call("sendonion", payload) return self.call("sendonion", payload)
@@ -1428,11 +1452,16 @@ class LightningRpc(UnixDomainSocketRpc):
payload.update({k: v for k, v in kwargs.items()}) payload.update({k: v for k, v in kwargs.items()})
return self.call("getsharedsecret", payload) return self.call("getsharedsecret", payload)
def keysend(self, destination, msatoshi, label=None, maxfeepercent=None, def keysend(self, destination, amount_msat=None, label=None, maxfeepercent=None,
retry_for=None, maxdelay=None, exemptfee=None, retry_for=None, maxdelay=None, exemptfee=None,
extratlvs=None): extratlvs=None, msatoshi=None):
""" """
""" """
# Deprecated usage
if msatoshi:
amount_msat = msatoshi
if amount_msat is None:
raise TypeError("keysend() missing 'amount_msat'")
if extratlvs is not None and not isinstance(extratlvs, dict): if extratlvs is not None and not isinstance(extratlvs, dict):
raise ValueError( raise ValueError(
@@ -1441,7 +1470,7 @@ class LightningRpc(UnixDomainSocketRpc):
payload = { payload = {
"destination": destination, "destination": destination,
"msatoshi": msatoshi, "amount_msat": amount_msat,
"label": label, "label": label,
"maxfeepercent": maxfeepercent, "maxfeepercent": maxfeepercent,
"retry_for": retry_for, "retry_for": retry_for,

View File

@@ -1152,23 +1152,23 @@ class LightningNode(object):
except RpcError: except RpcError:
return None return None
def dev_pay(self, bolt11, msatoshi=None, label=None, riskfactor=None, def dev_pay(self, bolt11, amount_msat=None, label=None, riskfactor=None,
maxfeepercent=None, retry_for=None, maxfeepercent=None, retry_for=None,
maxdelay=None, exemptfee=None, use_shadow=True, exclude=[]): maxdelay=None, exemptfee=None, use_shadow=True, exclude=[]):
"""Wrapper for rpc.dev_pay which suppresses the request schema""" """Wrapper for rpc.dev_pay which suppresses the request schema"""
# FIXME? dev options are not in schema # FIXME? dev options are not in schema
old_check = self.rpc.check_request_schemas old_check = self.rpc.check_request_schemas
self.rpc.check_request_schemas = False self.rpc.check_request_schemas = False
ret = self.rpc.dev_pay(bolt11, msatoshi, label, riskfactor, ret = self.rpc.dev_pay(bolt11, amount_msat, label, riskfactor,
maxfeepercent, retry_for, maxfeepercent, retry_for,
maxdelay, exemptfee, use_shadow, exclude) maxdelay, exemptfee, use_shadow, exclude)
self.rpc.check_request_schemas = old_check self.rpc.check_request_schemas = old_check
return ret return ret
def dev_invoice(self, msatoshi, label, description, expiry=None, fallbacks=None, preimage=None, exposeprivatechannels=None, cltv=None, dev_routes=None): def dev_invoice(self, amount_msat, label, description, expiry=None, fallbacks=None, preimage=None, exposeprivatechannels=None, cltv=None, dev_routes=None):
"""Wrapper for rpc.invoice() with dev-routes option""" """Wrapper for rpc.invoice() with dev-routes option"""
payload = { payload = {
"msatoshi": msatoshi, "amount_msat": amount_msat,
"label": label, "label": label,
"description": description, "description": description,
"expiry": expiry, "expiry": expiry,

View File

@@ -3,7 +3,7 @@
"type": "object", "type": "object",
"required": [ "required": [
"id", "id",
"msatoshi", "amount_msat",
"riskfactor" "riskfactor"
], ],
"properties": { "properties": {
@@ -11,7 +11,7 @@
"type": "pubkey", "type": "pubkey",
"description": "" "description": ""
}, },
"msatoshi": { "amount_msat": {
"type": "msat", "type": "msat",
"description": "" "description": ""
}, },

View File

@@ -3,12 +3,12 @@
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": [
"msatoshi", "amount_msat",
"label", "label",
"description" "description"
], ],
"properties": { "properties": {
"msatoshi": { "amount_msat": {
"type": "msat_or_any", "type": "msat_or_any",
"description": "" "description": ""
}, },

View File

@@ -4,13 +4,13 @@
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": [
"destination", "destination",
"msatoshi" "amount_msat"
], ],
"properties": { "properties": {
"destination": { "destination": {
"type": "pubkey" "type": "pubkey"
}, },
"msatoshi": { "amount_msat": {
"type": "msat" "type": "msat"
}, },
"label": { "label": {

View File

@@ -9,7 +9,7 @@
"bolt11": { "bolt11": {
"type": "string" "type": "string"
}, },
"msatoshi": { "amount_msat": {
"type": "msat" "type": "msat"
}, },
"label": { "label": {

View File

@@ -48,7 +48,7 @@
"bolt11": { "bolt11": {
"type": "string" "type": "string"
}, },
"msatoshi": { "amount_msat": {
"type": "msat" "type": "msat"
}, },
"destination": { "destination": {

View File

@@ -12,15 +12,17 @@
"items": { "items": {
"type": "object", "type": "object",
"required": [ "required": [
"msatoshi",
"id", "id",
"delay", "delay",
"channel" "channel"
], ],
"properties": { "properties": {
"msatoshi": { "amount_msat": {
"type": "msat" "type": "msat"
}, },
"msatoshi": {
"deprecated": "true"
},
"id": { "id": {
"type": "pubkey" "type": "pubkey"
}, },
@@ -39,7 +41,7 @@
"label": { "label": {
"type": "string" "type": "string"
}, },
"msatoshi": { "amount_msat": {
"type": "msat" "type": "msat"
}, },
"bolt11": { "bolt11": {

View File

@@ -1147,7 +1147,7 @@ static struct command_result *json_invoice(struct command *cmd,
info->cmd = cmd; info->cmd = cmd;
if (!param(cmd, buffer, params, if (!param(cmd, buffer, params,
p_req("msatoshi", param_positive_msat_or_any, &msatoshi_val), p_req("amount_msat|msatoshi", param_positive_msat_or_any, &msatoshi_val),
p_req("label", param_label, &info->label), p_req("label", param_label, &info->label),
p_req("description", param_escaped_string, &desc_val), p_req("description", param_escaped_string, &desc_val),
p_opt_def("expiry", param_time, &expiry, 3600*24*7), p_opt_def("expiry", param_time, &expiry, 3600*24*7),

View File

@@ -1289,7 +1289,7 @@ static struct command_result *json_sendonion(struct command *cmd,
p_opt_def("partid", param_u64, &partid, 0), p_opt_def("partid", param_u64, &partid, 0),
/* FIXME: parameter should be invstring now */ /* FIXME: parameter should be invstring now */
p_opt("bolt11", param_string, &invstring), p_opt("bolt11", param_string, &invstring),
p_opt_def("msatoshi", param_msat, &msat, AMOUNT_MSAT(0)), p_opt_def("amount_msat|msatoshi", param_msat, &msat, AMOUNT_MSAT(0)),
p_opt("destination", param_node_id, &destination), p_opt("destination", param_node_id, &destination),
p_opt("localofferid", param_sha256, &local_offer_id), p_opt("localofferid", param_sha256, &local_offer_id),
p_opt("groupid", param_u64, &group), p_opt("groupid", param_u64, &group),
@@ -1441,7 +1441,7 @@ static struct command_result *json_sendpay(struct command *cmd,
p_req("route", param_route_hops, &route), p_req("route", param_route_hops, &route),
p_req("payment_hash", param_sha256, &rhash), p_req("payment_hash", param_sha256, &rhash),
p_opt("label", param_escaped_string, &label), p_opt("label", param_escaped_string, &label),
p_opt("msatoshi", param_msat, &msat), p_opt("amount_msat|msatoshi", param_msat, &msat),
/* FIXME: parameter should be invstring now */ /* FIXME: parameter should be invstring now */
p_opt("bolt11", param_string, &invstring), p_opt("bolt11", param_string, &invstring),
p_opt("payment_secret", param_secret, &payment_secret), p_opt("payment_secret", param_secret, &payment_secret),

View File

@@ -1233,7 +1233,7 @@ static struct command_result *json_fetchinvoice(struct command *cmd,
invreq = tlv_invoice_request_new(sent); invreq = tlv_invoice_request_new(sent);
if (!param(cmd, buffer, params, if (!param(cmd, buffer, params,
p_req("offer", param_offer, &sent->offer), p_req("offer", param_offer, &sent->offer),
p_opt("msatoshi", param_msat, &msat), p_opt("amount_msat|msatoshi", param_msat, &msat),
p_opt("quantity", param_u64, &invreq->quantity), p_opt("quantity", param_u64, &invreq->quantity),
p_opt("recurrence_counter", param_number, p_opt("recurrence_counter", param_number,
&invreq->recurrence_counter), &invreq->recurrence_counter),
@@ -1647,7 +1647,7 @@ static struct command_result *json_sendinvoice(struct command *cmd,
if (!param(cmd, buffer, params, if (!param(cmd, buffer, params,
p_req("offer", param_offer, &sent->offer), p_req("offer", param_offer, &sent->offer),
p_req("label", param_label, &sent->inv_label), p_req("label", param_label, &sent->inv_label),
p_opt("msatoshi", param_msat, &msat), p_opt("amount_msat|msatoshi", param_msat, &msat),
p_opt_def("timeout", param_number, &timeout, 90), p_opt_def("timeout", param_number, &timeout, 90),
p_opt("quantity", param_u64, &sent->inv->quantity), p_opt("quantity", param_u64, &sent->inv->quantity),
NULL)) NULL))

View File

@@ -155,7 +155,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
#endif #endif
if (!param(cmd, buf, params, if (!param(cmd, buf, params,
p_req("destination", param_node_id, &destination), p_req("destination", param_node_id, &destination),
p_req("msatoshi", param_msat, &msat), p_req("amount_msat|msatoshi", param_msat, &msat),
p_opt("label", param_string, &label), p_opt("label", param_string, &label),
p_opt_def("maxfeepercent", param_millionths, p_opt_def("maxfeepercent", param_millionths,
&maxfee_pct_millionths, 500000), &maxfee_pct_millionths, 500000),
@@ -460,7 +460,7 @@ static struct command_result *htlc_accepted_call(struct command *cmd,
ki); ki);
plugin_log(cmd->plugin, LOG_INFORM, "Inserting a new invoice for keysend with payment_hash %s", type_to_string(tmpctx, struct sha256, &payment_hash)); plugin_log(cmd->plugin, LOG_INFORM, "Inserting a new invoice for keysend with payment_hash %s", type_to_string(tmpctx, struct sha256, &payment_hash));
json_add_string(req->js, "msatoshi", "any"); json_add_string(req->js, "amount_msat", "any");
json_add_string(req->js, "label", ki->label); json_add_string(req->js, "label", ki->label);
json_add_string(req->js, "description", "Spontaneous incoming payment through keysend"); json_add_string(req->js, "description", "Spontaneous incoming payment through keysend");
json_add_preimage(req->js, "preimage", &ki->payment_preimage); json_add_preimage(req->js, "preimage", &ki->payment_preimage);

View File

@@ -1554,7 +1554,7 @@ static struct command_result *payment_createonion_success(struct command *cmd,
json_object_end(req->js); json_object_end(req->js);
json_add_sha256(req->js, "payment_hash", p->payment_hash); json_add_sha256(req->js, "payment_hash", p->payment_hash);
json_add_amount_msat_only(req->js, "msatoshi", p->amount); json_add_amount_msat_only(req->js, "amount_msat", p->amount);
json_array_start(req->js, "shared_secrets"); json_array_start(req->js, "shared_secrets");
secrets = p->createonion_response->shared_secrets; secrets = p->createonion_response->shared_secrets;

View File

@@ -957,7 +957,7 @@ static struct command_result *json_pay(struct command *cmd,
if (!param(cmd, buf, params, if (!param(cmd, buf, params,
/* FIXME: parameter should be invstring now */ /* FIXME: parameter should be invstring now */
p_req("bolt11", param_string, &b11str), p_req("bolt11", param_string, &b11str),
p_opt("msatoshi", param_msat, &msat), p_opt("amount_msat|msatoshi", param_msat, &msat),
p_opt("label", param_string, &label), p_opt("label", param_string, &label),
p_opt_def("riskfactor", param_millionths, p_opt_def("riskfactor", param_millionths,
&riskfactor_millionths, 10000000), &riskfactor_millionths, 10000000),

View File

@@ -130,7 +130,7 @@ static struct command_result *json_getroute(struct command *cmd,
if (!param(cmd, buffer, params, if (!param(cmd, buffer, params,
p_req("id", param_node_id, &destination), p_req("id", param_node_id, &destination),
p_req("msatoshi", param_msat, &msat), p_req("amount_msat|msatoshi", param_msat, &msat),
p_req("riskfactor", param_millionths, &riskfactor_millionths), p_req("riskfactor", param_millionths, &riskfactor_millionths),
p_opt_def("cltv", param_number, &cltv, 9), p_opt_def("cltv", param_number, &cltv, 9),
p_opt_def("fromid", param_node_id, &source, local_id), p_opt_def("fromid", param_node_id, &source, local_id),

View File

@@ -104,7 +104,7 @@ def test_grpc_connect(node_factory):
print(response) print(response)
inv = stub.Invoice(nodepb.InvoiceRequest( inv = stub.Invoice(nodepb.InvoiceRequest(
msatoshi=AmountOrAny(any=True), amount_msat=AmountOrAny(any=True),
description="hello", description="hello",
label="lbl1", label="lbl1",
preimage=b"\x00" * 32, preimage=b"\x00" * 32,
@@ -119,7 +119,7 @@ def test_grpc_connect(node_factory):
with pytest.raises(Exception, match=r'Duplicate label'): with pytest.raises(Exception, match=r'Duplicate label'):
# This request creates a label collision # This request creates a label collision
stub.Invoice(nodepb.InvoiceRequest( stub.Invoice(nodepb.InvoiceRequest(
msatoshi=AmountOrAny(amount=Amount(msat=12345)), amount_msat=AmountOrAny(amount=Amount(msat=12345)),
description="hello", description="hello",
label="lbl1", label="lbl1",
)) ))

View File

@@ -2735,10 +2735,10 @@ def setup_multihtlc_test(node_factory, bitcoind):
nodes[-1].rpc.dev_ignore_htlcs(id=nodes[-2].info['id'], ignore=True) nodes[-1].rpc.dev_ignore_htlcs(id=nodes[-2].info['id'], ignore=True)
preimage = "0" * 64 preimage = "0" * 64
inv = nodes[0].rpc.invoice(msatoshi=10**8, label='x', description='desc', inv = nodes[0].rpc.invoice(amount_msat=10**8, label='x', description='desc',
preimage=preimage) preimage=preimage)
h = inv['payment_hash'] h = inv['payment_hash']
nodes[-1].rpc.invoice(msatoshi=10**8, label='x', description='desc', nodes[-1].rpc.invoice(amount_msat=10**8, label='x', description='desc',
preimage=preimage)['payment_hash'] preimage=preimage)['payment_hash']
# First, the failed attempts (paying wrong node). CLTV1 # First, the failed attempts (paying wrong node). CLTV1
@@ -3641,8 +3641,8 @@ We send an HTLC, and peer unilaterally closes: do we close upstream?
'dev-no-ping-timer': None}, 'dev-no-ping-timer': None},
{'dev-no-ping-timer': None}]) {'dev-no-ping-timer': None}])
ph1 = l3.rpc.invoice(msatoshi="10000sat", label='x1', description='desc2')['payment_hash'] ph1 = l3.rpc.invoice(amount_msat="10000sat", label='x1', description='desc2')['payment_hash']
ph2 = l3.rpc.invoice(msatoshi="10000sat", label='x2', description='desc2')['payment_hash'] ph2 = l3.rpc.invoice(amount_msat="10000sat", label='x2', description='desc2')['payment_hash']
route = l1.rpc.getroute(l3.info['id'], 1, 1)['route'] route = l1.rpc.getroute(l3.info['id'], 1, 1)['route']

View File

@@ -132,7 +132,7 @@ def test_invoice_preimage(node_factory):
invoice_preimage = "17b08f669513b7379728fc1abcea5eaf3448bc1eba55a68ca2cd1843409cdc04" invoice_preimage = "17b08f669513b7379728fc1abcea5eaf3448bc1eba55a68ca2cd1843409cdc04"
# Make invoice and pay it # Make invoice and pay it
inv = l2.rpc.invoice(msatoshi=123456, label="inv", description="?", preimage=invoice_preimage) inv = l2.rpc.invoice(amount_msat=123456, label="inv", description="?", preimage=invoice_preimage)
payment = l1.rpc.pay(inv['bolt11']) payment = l1.rpc.pay(inv['bolt11'])
# Check preimage was given. # Check preimage was given.
@@ -153,7 +153,7 @@ def test_invoice_routeboost(node_factory, bitcoind):
# Check routeboost. # Check routeboost.
# Make invoice and pay it # Make invoice and pay it
inv = l2.rpc.invoice(msatoshi=123456, label="inv1", description="?") inv = l2.rpc.invoice(amount_msat=123456, label="inv1", description="?")
# Check routeboost. # Check routeboost.
assert 'warning_private_unused' not in inv assert 'warning_private_unused' not in inv
assert 'warning_capacity' not in inv assert 'warning_capacity' not in inv
@@ -173,7 +173,7 @@ def test_invoice_routeboost(node_factory, bitcoind):
wait_channel_quiescent(l1, l2) wait_channel_quiescent(l1, l2)
# Due to reserve & fees, l1 doesn't have capacity to pay this. # Due to reserve & fees, l1 doesn't have capacity to pay this.
inv = l2.rpc.invoice(msatoshi=2 * (10**8) - 123456, label="inv2", description="?") inv = l2.rpc.invoice(amount_msat=2 * (10**8) - 123456, label="inv2", description="?")
# Check warning # Check warning
assert 'warning_capacity' in inv assert 'warning_capacity' in inv
assert 'warning_private_unused' not in inv assert 'warning_private_unused' not in inv
@@ -228,7 +228,7 @@ def test_invoice_routeboost_private(node_factory, bitcoind):
# Since there's only one route, it will reluctantly hint that even # Since there's only one route, it will reluctantly hint that even
# though it's private # though it's private
inv = l2.rpc.invoice(msatoshi=123456, label="inv0", description="?") inv = l2.rpc.invoice(amount_msat=123456, label="inv0", description="?")
assert 'warning_private_unused' not in inv assert 'warning_private_unused' not in inv
assert 'warning_capacity' not in inv assert 'warning_capacity' not in inv
assert 'warning_offline' not in inv assert 'warning_offline' not in inv
@@ -243,7 +243,7 @@ def test_invoice_routeboost_private(node_factory, bitcoind):
assert r['cltv_expiry_delta'] == 6 assert r['cltv_expiry_delta'] == 6
# If we explicitly say not to, it won't expose. # If we explicitly say not to, it won't expose.
inv = l2.rpc.invoice(msatoshi=123456, label="inv1", description="?", exposeprivatechannels=False) inv = l2.rpc.invoice(amount_msat=123456, label="inv1", description="?", exposeprivatechannels=False)
assert 'warning_private_unused' in inv assert 'warning_private_unused' in inv
assert 'warning_capacity' not in inv assert 'warning_capacity' not in inv
assert 'warning_offline' not in inv assert 'warning_offline' not in inv
@@ -252,7 +252,7 @@ def test_invoice_routeboost_private(node_factory, bitcoind):
assert 'routes' not in l1.rpc.decodepay(inv['bolt11']) assert 'routes' not in l1.rpc.decodepay(inv['bolt11'])
# If we ask for it, we get it. # If we ask for it, we get it.
inv = l2.rpc.invoice(msatoshi=123456, label="inv1a", description="?", exposeprivatechannels=scid) inv = l2.rpc.invoice(amount_msat=123456, label="inv1a", description="?", exposeprivatechannels=scid)
assert 'warning_private_unused' not in inv assert 'warning_private_unused' not in inv
assert 'warning_capacity' not in inv assert 'warning_capacity' not in inv
assert 'warning_offline' not in inv assert 'warning_offline' not in inv
@@ -267,7 +267,7 @@ def test_invoice_routeboost_private(node_factory, bitcoind):
assert r['cltv_expiry_delta'] == 6 assert r['cltv_expiry_delta'] == 6
# Similarly if we ask for an array. # Similarly if we ask for an array.
inv = l2.rpc.invoice(msatoshi=123456, label="inv1b", description="?", exposeprivatechannels=[scid]) inv = l2.rpc.invoice(amount_msat=123456, label="inv1b", description="?", exposeprivatechannels=[scid])
assert 'warning_private_unused' not in inv assert 'warning_private_unused' not in inv
assert 'warning_capacity' not in inv assert 'warning_capacity' not in inv
assert 'warning_offline' not in inv assert 'warning_offline' not in inv
@@ -290,7 +290,7 @@ def test_invoice_routeboost_private(node_factory, bitcoind):
# Make sure channel is totally public. # Make sure channel is totally public.
wait_for(lambda: [c['public'] for c in l2.rpc.listchannels(scid2)['channels']] == [True, True]) wait_for(lambda: [c['public'] for c in l2.rpc.listchannels(scid2)['channels']] == [True, True])
inv = l2.rpc.invoice(msatoshi=10**7, label="inv2", description="?") inv = l2.rpc.invoice(amount_msat=10**7, label="inv2", description="?")
print(inv) print(inv)
assert 'warning_deadends' in inv assert 'warning_deadends' in inv
assert 'warning_private_unused' not in inv assert 'warning_private_unused' not in inv
@@ -299,7 +299,7 @@ def test_invoice_routeboost_private(node_factory, bitcoind):
assert 'warning_mpp' not in inv assert 'warning_mpp' not in inv
# Unless we tell it to include it. # Unless we tell it to include it.
inv = l2.rpc.invoice(msatoshi=10**7, label="inv3", description="?", exposeprivatechannels=True) inv = l2.rpc.invoice(amount_msat=10**7, label="inv3", description="?", exposeprivatechannels=True)
assert 'warning_private_unused' not in inv assert 'warning_private_unused' not in inv
assert 'warning_capacity' not in inv assert 'warning_capacity' not in inv
assert 'warning_offline' not in inv assert 'warning_offline' not in inv
@@ -313,7 +313,7 @@ def test_invoice_routeboost_private(node_factory, bitcoind):
assert r['fee_proportional_millionths'] == 10 assert r['fee_proportional_millionths'] == 10
assert r['cltv_expiry_delta'] == 6 assert r['cltv_expiry_delta'] == 6
inv = l2.rpc.invoice(msatoshi=10**7, label="inv4", description="?", exposeprivatechannels=scid) inv = l2.rpc.invoice(amount_msat=10**7, label="inv4", description="?", exposeprivatechannels=scid)
assert 'warning_private_unused' not in inv assert 'warning_private_unused' not in inv
assert 'warning_capacity' not in inv assert 'warning_capacity' not in inv
assert 'warning_offline' not in inv assert 'warning_offline' not in inv
@@ -328,7 +328,7 @@ def test_invoice_routeboost_private(node_factory, bitcoind):
assert r['cltv_expiry_delta'] == 6 assert r['cltv_expiry_delta'] == 6
# Ask it explicitly to use a channel it can't (insufficient capacity) # Ask it explicitly to use a channel it can't (insufficient capacity)
inv = l2.rpc.invoice(msatoshi=(10**5) * 1000 + 1, label="inv5", description="?", exposeprivatechannels=scid2) inv = l2.rpc.invoice(amount_msat=(10**5) * 1000 + 1, label="inv5", description="?", exposeprivatechannels=scid2)
assert 'warning_private_unused' not in inv assert 'warning_private_unused' not in inv
assert 'warning_deadends' not in inv assert 'warning_deadends' not in inv
assert 'warning_capacity' in inv assert 'warning_capacity' in inv
@@ -336,7 +336,7 @@ def test_invoice_routeboost_private(node_factory, bitcoind):
assert 'warning_mpp' not in inv assert 'warning_mpp' not in inv
# Give it two options and it will pick one with suff capacity. # Give it two options and it will pick one with suff capacity.
inv = l2.rpc.invoice(msatoshi=(10**5) * 1000 + 1, label="inv6", description="?", exposeprivatechannels=[scid2, scid]) inv = l2.rpc.invoice(amount_msat=(10**5) * 1000 + 1, label="inv6", description="?", exposeprivatechannels=[scid2, scid])
assert 'warning_private_unused' not in inv assert 'warning_private_unused' not in inv
assert 'warning_capacity' not in inv assert 'warning_capacity' not in inv
assert 'warning_offline' not in inv assert 'warning_offline' not in inv
@@ -356,7 +356,7 @@ def test_invoice_routeboost_private(node_factory, bitcoind):
bitcoind.generate_block(1) bitcoind.generate_block(1)
wait_for(lambda: l2.rpc.listchannels(scid_dummy)['channels'] == []) wait_for(lambda: l2.rpc.listchannels(scid_dummy)['channels'] == [])
inv = l2.rpc.invoice(msatoshi=123456, label="inv7", description="?", exposeprivatechannels=scid) inv = l2.rpc.invoice(amount_msat=123456, label="inv7", description="?", exposeprivatechannels=scid)
assert 'warning_private_unused' not in inv assert 'warning_private_unused' not in inv
assert 'warning_capacity' not in inv assert 'warning_capacity' not in inv
assert 'warning_offline' not in inv assert 'warning_offline' not in inv
@@ -374,7 +374,7 @@ def test_invoice_routeboost_private(node_factory, bitcoind):
def test_invoice_expiry(node_factory, executor): def test_invoice_expiry(node_factory, executor):
l1, l2 = node_factory.line_graph(2, fundchannel=True) l1, l2 = node_factory.line_graph(2, fundchannel=True)
inv = l2.rpc.invoice(msatoshi=123000, label='test_pay', description='description', expiry=1)['bolt11'] inv = l2.rpc.invoice(amount_msat=123000, label='test_pay', description='description', expiry=1)['bolt11']
time.sleep(2) time.sleep(2)
with pytest.raises(RpcError): with pytest.raises(RpcError):
@@ -438,7 +438,7 @@ def test_invoice_expiry(node_factory, executor):
assert len(l2.rpc.listinvoices()['invoices']) == 0 assert len(l2.rpc.listinvoices()['invoices']) == 0
start = int(time.time()) start = int(time.time())
inv = l2.rpc.invoice(msatoshi=123000, label='inv_s', description='description', expiry=1)['bolt11'] inv = l2.rpc.invoice(amount_msat=123000, label='inv_s', description='description', expiry=1)['bolt11']
end = int(time.time()) end = int(time.time())
expiry = only_one(l2.rpc.listinvoices('inv_s')['invoices'])['expires_at'] expiry = only_one(l2.rpc.listinvoices('inv_s')['invoices'])['expires_at']
assert expiry >= start + 1 and expiry <= end + 1 assert expiry >= start + 1 and expiry <= end + 1
@@ -562,8 +562,8 @@ def test_waitanyinvoice_reversed(node_factory, executor):
def test_autocleaninvoice(node_factory): def test_autocleaninvoice(node_factory):
l1 = node_factory.get_node() l1 = node_factory.get_node()
l1.rpc.invoice(msatoshi=12300, label='inv1', description='description1', expiry=4) l1.rpc.invoice(amount_msat=12300, label='inv1', description='description1', expiry=4)
l1.rpc.invoice(msatoshi=12300, label='inv2', description='description2', expiry=12) l1.rpc.invoice(amount_msat=12300, label='inv2', description='description2', expiry=12)
l1.rpc.autocleaninvoice(cycle_seconds=8, expired_by=2) l1.rpc.autocleaninvoice(cycle_seconds=8, expired_by=2)
start_time = time.time() start_time = time.time()
@@ -633,7 +633,7 @@ def test_amountless_invoice(node_factory):
details = l1.rpc.decodepay(inv) details = l1.rpc.decodepay(inv)
assert('msatoshi' not in details) assert('msatoshi' not in details)
l1.rpc.pay(inv, msatoshi=1337) l1.rpc.pay(inv, amount_msat=1337)
i = l2.rpc.listinvoices()['invoices'] i = l2.rpc.listinvoices()['invoices']
assert(len(i) == 1) assert(len(i) == 1)

View File

@@ -2074,7 +2074,7 @@ def test_unicode_rpc(node_factory, executor, bitcoind):
node = node_factory.get_node() node = node_factory.get_node()
desc = "Some candy 🍬 and a nice glass of milk 🥛." desc = "Some candy 🍬 and a nice glass of milk 🥛."
node.rpc.invoice(msatoshi=42, label=desc, description=desc) node.rpc.invoice(amount_msat=42, label=desc, description=desc)
invoices = node.rpc.listinvoices()['invoices'] invoices = node.rpc.listinvoices()['invoices']
assert(len(invoices) == 1) assert(len(invoices) == 1)
assert(invoices[0]['description'] == desc) assert(invoices[0]['description'] == desc)

View File

@@ -102,7 +102,7 @@ def test_pay_limits(node_factory):
# Fee too high. # Fee too high.
err = r'Fee exceeds our fee budget: [1-9]msat > 0msat, discarding route' err = r'Fee exceeds our fee budget: [1-9]msat > 0msat, discarding route'
with pytest.raises(RpcError, match=err) as err: with pytest.raises(RpcError, match=err) as err:
l1.rpc.call('pay', {'bolt11': inv['bolt11'], 'msatoshi': 100000, 'maxfeepercent': 0.0001, 'exemptfee': 0}) l1.rpc.call('pay', {'bolt11': inv['bolt11'], 'amount_msat': 100000, 'maxfeepercent': 0.0001, 'exemptfee': 0})
assert err.value.error['code'] == PAY_STOPPED_RETRYING assert err.value.error['code'] == PAY_STOPPED_RETRYING
@@ -119,7 +119,7 @@ def test_pay_limits(node_factory):
failmsg = r'CLTV delay exceeds our CLTV budget' failmsg = r'CLTV delay exceeds our CLTV budget'
# Delay too high. # Delay too high.
with pytest.raises(RpcError, match=failmsg) as err: with pytest.raises(RpcError, match=failmsg) as err:
l1.rpc.call('pay', {'bolt11': inv['bolt11'], 'msatoshi': 100000, 'maxdelay': 0}) l1.rpc.call('pay', {'bolt11': inv['bolt11'], 'amount_msat': 100000, 'maxdelay': 0})
assert err.value.error['code'] == PAY_STOPPED_RETRYING assert err.value.error['code'] == PAY_STOPPED_RETRYING
# Should also have retried two more times. # Should also have retried two more times.
@@ -131,10 +131,10 @@ def test_pay_limits(node_factory):
# This fails! # This fails!
err = r'Fee exceeds our fee budget: 2msat > 1msat, discarding route' err = r'Fee exceeds our fee budget: 2msat > 1msat, discarding route'
with pytest.raises(RpcError, match=err) as err: with pytest.raises(RpcError, match=err) as err:
l1.rpc.pay(bolt11=inv['bolt11'], msatoshi=100000, maxfee=1) l1.rpc.pay(bolt11=inv['bolt11'], amount_msat=100000, maxfee=1)
# This works, because fee is less than exemptfee. # This works, because fee is less than exemptfee.
l1.dev_pay(inv['bolt11'], msatoshi=100000, maxfeepercent=0.0001, l1.dev_pay(inv['bolt11'], amount_msat=100000, maxfeepercent=0.0001,
exemptfee=2000, use_shadow=False) exemptfee=2000, use_shadow=False)
status = l1.rpc.call('paystatus', {'bolt11': inv['bolt11']})['pay'][3]['attempts'] status = l1.rpc.call('paystatus', {'bolt11': inv['bolt11']})['pay'][3]['attempts']
assert len(status) == 1 assert len(status) == 1
@@ -323,7 +323,7 @@ def test_pay_error_update_fees(node_factory):
l1, l2, l3 = node_factory.line_graph(3, fundchannel=True, wait_for_announce=True) l1, l2, l3 = node_factory.line_graph(3, fundchannel=True, wait_for_announce=True)
# Don't include any routehints in first invoice. # Don't include any routehints in first invoice.
inv1 = l3.dev_invoice(msatoshi=123000, inv1 = l3.dev_invoice(amount_msat=123000,
label='test_pay_error_update_fees', label='test_pay_error_update_fees',
description='description', description='description',
dev_routes=[]) dev_routes=[])
@@ -369,7 +369,7 @@ def test_pay_optional_args(node_factory):
# root of a payment tree with the bolt11 invoice). # root of a payment tree with the bolt11 invoice).
anyinv = l2.rpc.invoice('any', 'any_pay', 'desc')['bolt11'] anyinv = l2.rpc.invoice('any', 'any_pay', 'desc')['bolt11']
l1.dev_pay(anyinv, label='desc', msatoshi=500, use_shadow=False) l1.dev_pay(anyinv, label='desc', amount_msat=500, use_shadow=False)
payment3 = l1.rpc.listsendpays(anyinv)['payments'] payment3 = l1.rpc.listsendpays(anyinv)['payments']
assert len(payment3) == 1 assert len(payment3) == 1
assert payment3[0]['label'] == 'desc' assert payment3[0]['label'] == 'desc'
@@ -1628,7 +1628,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
# l3 will see a reconnect from l4 when l4 restarts. # l3 will see a reconnect from l4 when l4 restarts.
l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True, opts=[{}] * 2 + [{'dev-no-reconnect': None, 'may_reconnect': True}] * 2) l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True, opts=[{}] * 2 + [{'dev-no-reconnect': None, 'may_reconnect': True}] * 2)
inv = l4.rpc.invoice(msatoshi=10**8, label='x', description='desc') inv = l4.rpc.invoice(amount_msat=10**8, label='x', description='desc')
h = inv['payment_hash'] h = inv['payment_hash']
l4.rpc.dev_ignore_htlcs(id=l3.info['id'], ignore=True) l4.rpc.dev_ignore_htlcs(id=l3.info['id'], ignore=True)
@@ -1850,7 +1850,7 @@ def test_pay_routeboost(node_factory, bitcoind):
'fee_base_msat': 1000, 'fee_base_msat': 1000,
'fee_proportional_millionths': 10, 'fee_proportional_millionths': 10,
'cltv_expiry_delta': 6}] 'cltv_expiry_delta': 6}]
inv = l5.dev_invoice(msatoshi=10**5, inv = l5.dev_invoice(amount_msat=10**5,
label='test_pay_routeboost2', label='test_pay_routeboost2',
description='test_pay_routeboost2', description='test_pay_routeboost2',
dev_routes=[routel3l4l5]) dev_routes=[routel3l4l5])
@@ -1872,7 +1872,7 @@ def test_pay_routeboost(node_factory, bitcoind):
'fee_base_msat': 1000, 'fee_base_msat': 1000,
'fee_proportional_millionths': 10, 'fee_proportional_millionths': 10,
'cltv_expiry_delta': 6}] 'cltv_expiry_delta': 6}]
inv = l5.dev_invoice(msatoshi=10**5, inv = l5.dev_invoice(amount_msat=10**5,
label='test_pay_routeboost5', label='test_pay_routeboost5',
description='test_pay_routeboost5', description='test_pay_routeboost5',
dev_routes=[routel3l4l5, routel3l5]) dev_routes=[routel3l4l5, routel3l5])
@@ -2171,7 +2171,7 @@ def test_setchannel_routing(node_factory, bitcoind):
l1.rpc.getroute(l3.info['id'], 4001793, 1, fuzzpercent=0)["route"] l1.rpc.getroute(l3.info['id'], 4001793, 1, fuzzpercent=0)["route"]
# We should consider this unroutable! (MPP is disabled!) # We should consider this unroutable! (MPP is disabled!)
inv = l3.dev_invoice(msatoshi=4001793, inv = l3.dev_invoice(amount_msat=4001793,
label='test_setchannel_1', label='test_setchannel_1',
description='desc', description='desc',
dev_routes=[]) dev_routes=[])
@@ -2237,7 +2237,7 @@ def test_setchannel_routing(node_factory, bitcoind):
l1.rpc.waitsendpay(inv['payment_hash']) l1.rpc.waitsendpay(inv['payment_hash'])
# Check that this one warns about capacity! # Check that this one warns about capacity!
inv = l3.rpc.call('invoice', {'msatoshi': 4001793, inv = l3.rpc.call('invoice', {'amount_msat': 4001793,
'label': 'test_setchannel_4', 'label': 'test_setchannel_4',
'description': 'desc'}) 'description': 'desc'})
assert 'warning_capacity' in inv assert 'warning_capacity' in inv
@@ -2730,7 +2730,7 @@ def test_tlv_or_legacy(node_factory, bitcoind):
# We need to force l3 to provide route hint from l2 (it won't normally, # We need to force l3 to provide route hint from l2 (it won't normally,
# since it sees l2 as a dead end). # since it sees l2 as a dead end).
inv = l3.dev_invoice(msatoshi=10000, inv = l3.dev_invoice(amount_msat=10000,
label="test_tlv1", label="test_tlv1",
description="test_tlv1", description="test_tlv1",
dev_routes=[[{'id': l2.info['id'], dev_routes=[[{'id': l2.info['id'],
@@ -3009,7 +3009,7 @@ def test_partial_payment(node_factory, bitcoind, executor):
l1.rpc.sendpay( l1.rpc.sendpay(
route=r134, route=r134,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=1000, amount_msat=1000,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=1, partid=1,
@@ -3021,7 +3021,7 @@ def test_partial_payment(node_factory, bitcoind, executor):
l1.rpc.sendpay( l1.rpc.sendpay(
route=r124, route=r124,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=499, amount_msat=499,
payment_secret=paysecret, payment_secret=paysecret,
groupid=1, groupid=1,
) )
@@ -3031,7 +3031,7 @@ def test_partial_payment(node_factory, bitcoind, executor):
l1.rpc.sendpay( l1.rpc.sendpay(
route=r124, route=r124,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=999, amount_msat=999,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=2, partid=2,
@@ -3042,7 +3042,7 @@ def test_partial_payment(node_factory, bitcoind, executor):
l1.rpc.sendpay( l1.rpc.sendpay(
route=r124, route=r124,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=1000, amount_msat=1000,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=2, partid=2,
@@ -3054,7 +3054,7 @@ def test_partial_payment(node_factory, bitcoind, executor):
l1.rpc.sendpay( l1.rpc.sendpay(
route=r124, route=r124,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=1000, amount_msat=1000,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=3, partid=3,
@@ -3066,7 +3066,7 @@ def test_partial_payment(node_factory, bitcoind, executor):
l1.rpc.sendpay( l1.rpc.sendpay(
route=r124, route=r124,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=1000, amount_msat=1000,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=1, partid=1,
@@ -3076,7 +3076,7 @@ def test_partial_payment(node_factory, bitcoind, executor):
l1.rpc.sendpay( l1.rpc.sendpay(
route=r134, route=r134,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=1000, amount_msat=1000,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=1, partid=1,
@@ -3086,7 +3086,7 @@ def test_partial_payment(node_factory, bitcoind, executor):
l1.rpc.sendpay( l1.rpc.sendpay(
route=r124, route=r124,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=1000, amount_msat=1000,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=2, partid=2,
@@ -3125,7 +3125,7 @@ def test_partial_payment(node_factory, bitcoind, executor):
pay = l1.rpc.sendpay( pay = l1.rpc.sendpay(
route=r124, route=r124,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=1000, amount_msat=1000,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=2, partid=2,
@@ -3138,7 +3138,7 @@ def test_partial_payment(node_factory, bitcoind, executor):
l1.rpc.sendpay( l1.rpc.sendpay(
route=r124, route=r124,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=1000, amount_msat=1000,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=3, partid=3,
@@ -3155,7 +3155,7 @@ def test_partial_payment_timeout(node_factory, bitcoind):
l1.rpc.sendpay( l1.rpc.sendpay(
route=route, route=route,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=1000, amount_msat=1000,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=1, partid=1,
@@ -3175,7 +3175,7 @@ def test_partial_payment_timeout(node_factory, bitcoind):
l1.rpc.sendpay( l1.rpc.sendpay(
route=route, route=route,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=1000, amount_msat=1000,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=1, partid=1,
@@ -3184,7 +3184,7 @@ def test_partial_payment_timeout(node_factory, bitcoind):
l1.rpc.sendpay( l1.rpc.sendpay(
route=route, route=route,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=1000, amount_msat=1000,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=2, partid=2,
@@ -3210,7 +3210,7 @@ def test_partial_payment_restart(node_factory, bitcoind):
l1.rpc.sendpay( l1.rpc.sendpay(
route=route, route=route,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=1000, amount_msat=1000,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=1, partid=1,
@@ -3228,7 +3228,7 @@ def test_partial_payment_restart(node_factory, bitcoind):
l1.rpc.sendpay( l1.rpc.sendpay(
route=route, route=route,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
msatoshi=1000, amount_msat=1000,
bolt11=inv['bolt11'], bolt11=inv['bolt11'],
payment_secret=paysecret, payment_secret=paysecret,
partid=2, partid=2,
@@ -3253,7 +3253,7 @@ def test_partial_payment_htlc_loss(node_factory, bitcoind):
route = l1.rpc.getroute(l3.info['id'], 500, 1)['route'] route = l1.rpc.getroute(l3.info['id'], 500, 1)['route']
l1.rpc.sendpay(route=route, payment_hash=inv['payment_hash'], msatoshi=1000, bolt11=inv['bolt11'], payment_secret=paysecret, partid=1) l1.rpc.sendpay(route=route, payment_hash=inv['payment_hash'], amount_msat=1000, bolt11=inv['bolt11'], payment_secret=paysecret, partid=1)
wait_for(lambda: not only_one(l2.rpc.listpeers(l3.info['id'])['peers'])['connected']) wait_for(lambda: not only_one(l2.rpc.listpeers(l3.info['id'])['peers'])['connected'])
l2.rpc.dev_fail(l3.info['id']) l2.rpc.dev_fail(l3.info['id'])
@@ -3379,18 +3379,18 @@ caused a crash in 0.8.0, so we then disallowed it.
with pytest.raises(RpcError, match=r'Do not specify msatoshi \(1001msat\) without' with pytest.raises(RpcError, match=r'Do not specify msatoshi \(1001msat\) without'
' partid: if you do, it must be exactly' ' partid: if you do, it must be exactly'
r' the final amount \(1000msat\)'): r' the final amount \(1000msat\)'):
l1.rpc.sendpay(route=l1.rpc.getroute(l2.info['id'], 1000, 1)['route'], payment_hash=inv['payment_hash'], msatoshi=1001, bolt11=inv['bolt11'], payment_secret=inv['payment_secret']) l1.rpc.sendpay(route=l1.rpc.getroute(l2.info['id'], 1000, 1)['route'], payment_hash=inv['payment_hash'], amount_msat=1001, bolt11=inv['bolt11'], payment_secret=inv['payment_secret'])
with pytest.raises(RpcError, match=r'Do not specify msatoshi \(999msat\) without' with pytest.raises(RpcError, match=r'Do not specify msatoshi \(999msat\) without'
' partid: if you do, it must be exactly' ' partid: if you do, it must be exactly'
r' the final amount \(1000msat\)'): r' the final amount \(1000msat\)'):
l1.rpc.sendpay(route=l1.rpc.getroute(l2.info['id'], 1000, 1)['route'], payment_hash=inv['payment_hash'], msatoshi=999, bolt11=inv['bolt11'], payment_secret=inv['payment_secret']) l1.rpc.sendpay(route=l1.rpc.getroute(l2.info['id'], 1000, 1)['route'], payment_hash=inv['payment_hash'], amount_msat=999, bolt11=inv['bolt11'], payment_secret=inv['payment_secret'])
# Can't send MPP payment which pays any more than amount. # Can't send MPP payment which pays any more than amount.
with pytest.raises(RpcError, match=r'Final amount 1001msat is greater than 1000msat, despite MPP'): with pytest.raises(RpcError, match=r'Final amount 1001msat is greater than 1000msat, despite MPP'):
l1.rpc.sendpay(route=l1.rpc.getroute(l2.info['id'], 1001, 1)['route'], payment_hash=inv['payment_hash'], msatoshi=1000, bolt11=inv['bolt11'], partid=1, payment_secret=inv['payment_secret']) l1.rpc.sendpay(route=l1.rpc.getroute(l2.info['id'], 1001, 1)['route'], payment_hash=inv['payment_hash'], amount_msat=1000, bolt11=inv['bolt11'], partid=1, payment_secret=inv['payment_secret'])
# But this works # But this works
l1.rpc.sendpay(route=l1.rpc.getroute(l2.info['id'], 1001, 1)['route'], payment_hash=inv['payment_hash'], msatoshi=1001, bolt11=inv['bolt11'], payment_secret=inv['payment_secret']) l1.rpc.sendpay(route=l1.rpc.getroute(l2.info['id'], 1001, 1)['route'], payment_hash=inv['payment_hash'], amount_msat=1001, bolt11=inv['bolt11'], payment_secret=inv['payment_secret'])
l1.rpc.waitsendpay(inv['payment_hash']) l1.rpc.waitsendpay(inv['payment_hash'])
inv = only_one(l2.rpc.listinvoices('inv')['invoices']) inv = only_one(l2.rpc.listinvoices('inv')['invoices'])
@@ -3602,13 +3602,13 @@ def test_keysend_routehint(node_factory):
# Without any hints we should fail: # Without any hints we should fail:
with pytest.raises(RpcError): with pytest.raises(RpcError):
l1.rpc.call("keysend", payload={'destination': dest, 'msatoshi': amt}) l1.rpc.call("keysend", payload={'destination': dest, 'amount_msat': amt})
# We should also fail with only non-working hints: # We should also fail with only non-working hints:
with pytest.raises(RpcError): with pytest.raises(RpcError):
l1.rpc.call("keysend", payload={'destination': dest, 'msatoshi': amt, 'routehints': routehints[1:]}) l1.rpc.call("keysend", payload={'destination': dest, 'amount_msat': amt, 'routehints': routehints[1:]})
l1.rpc.call("keysend", payload={'destination': dest, 'msatoshi': amt, 'routehints': routehints}) l1.rpc.call("keysend", payload={'destination': dest, 'amount_msat': amt, 'routehints': routehints})
invs = l3.rpc.listinvoices()['invoices'] invs = l3.rpc.listinvoices()['invoices']
assert(len(invs) == 1) assert(len(invs) == 1)
@@ -4594,25 +4594,25 @@ def test_fetchinvoice(node_factory, bitcoind):
assert len(l3.rpc.listinvoices(offer_id=offer1['offer_id'])['invoices']) == 2 assert len(l3.rpc.listinvoices(offer_id=offer1['offer_id'])['invoices']) == 2
# We can also set the amount explicitly, to tip. # We can also set the amount explicitly, to tip.
inv1 = l1.rpc.call('fetchinvoice', {'offer': offer1['bolt12'], 'msatoshi': 3}) inv1 = l1.rpc.call('fetchinvoice', {'offer': offer1['bolt12'], 'amount_msat': 3})
assert l1.rpc.call('decode', [inv1['invoice']])['amount_msat'] == 3 assert l1.rpc.call('decode', [inv1['invoice']])['amount_msat'] == 3
l1.rpc.pay(inv1['invoice']) l1.rpc.pay(inv1['invoice'])
# More than ~5x expected is rejected as absurd (it's actually a divide test, # More than ~5x expected is rejected as absurd (it's actually a divide test,
# which means we need 15 here, not 11). # which means we need 15 here, not 11).
with pytest.raises(RpcError, match="Remote node sent failure message.*Amount vastly exceeds 2msat"): with pytest.raises(RpcError, match="Remote node sent failure message.*Amount vastly exceeds 2msat"):
l1.rpc.call('fetchinvoice', {'offer': offer1['bolt12'], 'msatoshi': 15}) l1.rpc.call('fetchinvoice', {'offer': offer1['bolt12'], 'amount_msat': 15})
# Underpay is rejected. # Underpay is rejected.
with pytest.raises(RpcError, match="Remote node sent failure message.*Amount must be at least 2msat"): with pytest.raises(RpcError, match="Remote node sent failure message.*Amount must be at least 2msat"):
l1.rpc.call('fetchinvoice', {'offer': offer1['bolt12'], 'msatoshi': 1}) l1.rpc.call('fetchinvoice', {'offer': offer1['bolt12'], 'amount_msat': 1})
# If no amount is specified in offer, one must be in invoice. # If no amount is specified in offer, one must be in invoice.
offer_noamount = l3.rpc.call('offer', {'amount': 'any', offer_noamount = l3.rpc.call('offer', {'amount': 'any',
'description': 'any amount test'}) 'description': 'any amount test'})
with pytest.raises(RpcError, match="msatoshi parameter required"): with pytest.raises(RpcError, match="msatoshi parameter required"):
l1.rpc.call('fetchinvoice', {'offer': offer_noamount['bolt12']}) l1.rpc.call('fetchinvoice', {'offer': offer_noamount['bolt12']})
inv1 = l1.rpc.call('fetchinvoice', {'offer': offer_noamount['bolt12'], 'msatoshi': 100}) inv1 = l1.rpc.call('fetchinvoice', {'offer': offer_noamount['bolt12'], 'amount_msat': 100})
# But amount won't appear in changes # But amount won't appear in changes
assert 'msat' not in inv1['changes'] assert 'msat' not in inv1['changes']
@@ -5070,11 +5070,11 @@ def test_setchannel_enforcement_delay(node_factory, bitcoind):
chanid1 = only_one(l1.rpc.getpeer(l2.info['id'])['channels'])['short_channel_id'] chanid1 = only_one(l1.rpc.getpeer(l2.info['id'])['channels'])['short_channel_id']
chanid2 = only_one(l2.rpc.getpeer(l3.info['id'])['channels'])['short_channel_id'] chanid2 = only_one(l2.rpc.getpeer(l3.info['id'])['channels'])['short_channel_id']
route = [{'msatoshi': 1011, route = [{'amount_msat': 1011,
'id': l2.info['id'], 'id': l2.info['id'],
'delay': 20, 'delay': 20,
'channel': chanid1}, 'channel': chanid1},
{'msatoshi': 1000, {'amount_msat': 1000,
'id': l3.info['id'], 'id': l3.info['id'],
'delay': 10, 'delay': 10,
'channel': chanid2}] 'channel': chanid2}]
@@ -5097,7 +5097,7 @@ def test_setchannel_enforcement_delay(node_factory, bitcoind):
l1.rpc.waitsendpay(inv['payment_hash']) l1.rpc.waitsendpay(inv['payment_hash'])
# Test increased amount. # Test increased amount.
route[0]['msatoshi'] += 1 route[0]['amount_msat'] += 1
inv = l3.rpc.invoice(1000, "test3", "test3") inv = l3.rpc.invoice(1000, "test3", "test3")
l1.rpc.sendpay(route, l1.rpc.sendpay(route,
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
@@ -5159,20 +5159,20 @@ def test_sendpay_grouping(node_factory, bitcoind):
) )
wait_for(lambda: len(l1.rpc.listnodes()['nodes']) == 3) wait_for(lambda: len(l1.rpc.listnodes()['nodes']) == 3)
inv = l3.rpc.invoice(msatoshi='any', label='lbl1', description='desc')['bolt11'] inv = l3.rpc.invoice(amount_msat='any', label='lbl1', description='desc')['bolt11']
l3.stop() # Stop recipient so the first attempt fails l3.stop() # Stop recipient so the first attempt fails
assert(len(l1.db.query("SELECT * FROM payments")) == 0) assert(len(l1.db.query("SELECT * FROM payments")) == 0)
assert(len(l1.rpc.listpays()['pays']) == 0) assert(len(l1.rpc.listpays()['pays']) == 0)
with pytest.raises(RpcError, match=r'Ran out of routes to try after [0-9]+ attempts'): with pytest.raises(RpcError, match=r'Ran out of routes to try after [0-9]+ attempts'):
l1.rpc.pay(inv, msatoshi='100000msat') l1.rpc.pay(inv, amount_msat='100000msat')
# After this one invocation we have one entry in `listpays` # After this one invocation we have one entry in `listpays`
assert(len(l1.rpc.listpays()['pays']) == 1) assert(len(l1.rpc.listpays()['pays']) == 1)
with pytest.raises(RpcError, match=r'Ran out of routes to try after [0-9]+ attempts'): with pytest.raises(RpcError, match=r'Ran out of routes to try after [0-9]+ attempts'):
l1.rpc.pay(inv, msatoshi='200000msat') l1.rpc.pay(inv, amount_msat='200000msat')
# Surprise: we should have 2 entries after 2 invocations # Surprise: we should have 2 entries after 2 invocations
assert(len(l1.rpc.listpays()['pays']) == 2) assert(len(l1.rpc.listpays()['pays']) == 2)
@@ -5185,7 +5185,7 @@ def test_sendpay_grouping(node_factory, bitcoind):
wait_for(lambda: only_one(l3.rpc.listpeers()['peers'])['connected'] is True) wait_for(lambda: only_one(l3.rpc.listpeers()['peers'])['connected'] is True)
scid = l3.rpc.listpeers()['peers'][0]['channels'][0]['short_channel_id'] scid = l3.rpc.listpeers()['peers'][0]['channels'][0]['short_channel_id']
wait_for(lambda: [c['active'] for c in l1.rpc.listchannels(scid)['channels']] == [True, True]) wait_for(lambda: [c['active'] for c in l1.rpc.listchannels(scid)['channels']] == [True, True])
l1.rpc.pay(inv, msatoshi='420000msat') l1.rpc.pay(inv, amount_msat='420000msat')
# And finally we should have all 3 attempts to pay the invoice # And finally we should have all 3 attempts to pay the invoice
pays = l1.rpc.listpays()['pays'] pays = l1.rpc.listpays()['pays']
@@ -5221,7 +5221,7 @@ def test_legacyonion(node_factory, bitcoind):
"id": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59" "id": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59"
}, },
"payment_hash": "66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925", "payment_hash": "66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925",
"msatoshi": "10000msat", "amount_msat": "10000msat",
"shared_secrets": [ "shared_secrets": [
"bd29a24ea1fa5cab1677b22f4980f6aa115d470c2e3052cb08ca7d636441bfd5", "bd29a24ea1fa5cab1677b22f4980f6aa115d470c2e3052cb08ca7d636441bfd5",
"7d70d337a6b898373386d7d2cff05ca8f4d81123f63cf911aa064a6d8849f972" "7d70d337a6b898373386d7d2cff05ca8f4d81123f63cf911aa064a6d8849f972"
@@ -5244,7 +5244,7 @@ def test_pay_manual_exclude(node_factory, bitcoind):
chan23 = l2.rpc.listpeers(l3_id)['peers'][0]['channels'][0] chan23 = l2.rpc.listpeers(l3_id)['peers'][0]['channels'][0]
scid12 = chan12['short_channel_id'] + '/' + str(chan12['direction']) scid12 = chan12['short_channel_id'] + '/' + str(chan12['direction'])
scid23 = chan23['short_channel_id'] + '/' + str(chan23['direction']) scid23 = chan23['short_channel_id'] + '/' + str(chan23['direction'])
inv = l3.rpc.invoice(msatoshi=123000, label='label1', description='desc')['bolt11'] inv = l3.rpc.invoice(amount_msat=123000, label='label1', description='desc')['bolt11']
# Exclude the payer node id # Exclude the payer node id
with pytest.raises(RpcError, match=r'Payer is manually excluded'): with pytest.raises(RpcError, match=r'Payer is manually excluded'):
l1.rpc.pay(inv, exclude=[l1_id]) l1.rpc.pay(inv, exclude=[l1_id])
@@ -5277,7 +5277,7 @@ def test_pay_bolt11_metadata(node_factory, bitcoind):
# After CI started failing, I *also* hacked it to set expiry to BIGNUM. # After CI started failing, I *also* hacked it to set expiry to BIGNUM.
inv = "lnbcrt1230n1p3yzgcxsp5q8g040f9rl9mu2unkjuj0vn262s6nyrhz5hythk3ueu2lfzahmzspp5ve584t0cv27hwmy0cx9ca8uwyqyfw9y9dm3r8vus9fv36r2l9yjsdq8v3jhxccmq6w35xjueqd9ejqmt9w3skgct5vyxqxra2q2qcqp99q2sqqqqqysgqfw6efxpzk5x5vfj8se46yg667x5cvhyttnmuqyk0q7rmhx3gs249qhtdggnek8c5adm2pztkjddlwyn2art2zg9xap2ckczzl3fzz4qqsej6mf" inv = "lnbcrt1230n1p3yzgcxsp5q8g040f9rl9mu2unkjuj0vn262s6nyrhz5hythk3ueu2lfzahmzspp5ve584t0cv27hwmy0cx9ca8uwyqyfw9y9dm3r8vus9fv36r2l9yjsdq8v3jhxccmq6w35xjueqd9ejqmt9w3skgct5vyxqxra2q2qcqp99q2sqqqqqysgqfw6efxpzk5x5vfj8se46yg667x5cvhyttnmuqyk0q7rmhx3gs249qhtdggnek8c5adm2pztkjddlwyn2art2zg9xap2ckczzl3fzz4qqsej6mf"
# Make l2 "know" about this invoice. # Make l2 "know" about this invoice.
l2.rpc.invoice(msatoshi=123000, label='label1', description='desc', preimage='00' * 32) l2.rpc.invoice(amount_msat=123000, label='label1', description='desc', preimage='00' * 32)
with pytest.raises(RpcError, match=r'WIRE_INVALID_ONION_PAYLOAD'): with pytest.raises(RpcError, match=r'WIRE_INVALID_ONION_PAYLOAD'):
l1.rpc.pay(inv) l1.rpc.pay(inv)

View File

@@ -396,7 +396,7 @@ def test_pay_plugin(node_factory):
l1.rpc.call('pay') l1.rpc.call('pay')
# Make sure usage messages are present. # Make sure usage messages are present.
msg = 'pay bolt11 [msatoshi] [label] [riskfactor] [maxfeepercent] '\ msg = 'pay bolt11 [amount_msat] [label] [riskfactor] [maxfeepercent] '\
'[retry_for] [maxdelay] [exemptfee] [localofferid] [exclude] '\ '[retry_for] [maxdelay] [exemptfee] [localofferid] [exclude] '\
'[maxfee] [description]' '[maxfee] [description]'
if DEVELOPER: if DEVELOPER:
@@ -1076,7 +1076,7 @@ def test_htlc_accepted_hook_resolve(node_factory):
{} {}
], wait_for_announce=True) ], wait_for_announce=True)
inv = l3.rpc.invoice(msatoshi=1000, label="lbl", description="desc", preimage="00" * 32)['bolt11'] inv = l3.rpc.invoice(amount_msat=1000, label="lbl", description="desc", preimage="00" * 32)['bolt11']
l1.rpc.pay(inv) l1.rpc.pay(inv)
# And the invoice must still be unpaid # And the invoice must still be unpaid
@@ -1093,7 +1093,7 @@ def test_htlc_accepted_hook_direct_restart(node_factory, executor):
'plugin': os.path.join(os.getcwd(), 'tests/plugins/hold_htlcs.py')} 'plugin': os.path.join(os.getcwd(), 'tests/plugins/hold_htlcs.py')}
]) ])
i1 = l2.rpc.invoice(msatoshi=1000, label="direct", description="desc")['bolt11'] i1 = l2.rpc.invoice(amount_msat=1000, label="direct", description="desc")['bolt11']
f1 = executor.submit(l1.rpc.pay, i1) f1 = executor.submit(l1.rpc.pay, i1)
l2.daemon.wait_for_log(r'Holding onto an incoming htlc for 10 seconds') l2.daemon.wait_for_log(r'Holding onto an incoming htlc for 10 seconds')
@@ -1126,7 +1126,7 @@ def test_htlc_accepted_hook_forward_restart(node_factory, executor):
{'may_reconnect': True}, {'may_reconnect': True},
], wait_for_announce=True) ], wait_for_announce=True)
i1 = l3.rpc.invoice(msatoshi=1000, label="direct", description="desc")['bolt11'] i1 = l3.rpc.invoice(amount_msat=1000, label="direct", description="desc")['bolt11']
f1 = executor.submit(l1.dev_pay, i1, use_shadow=False) f1 = executor.submit(l1.dev_pay, i1, use_shadow=False)
l2.daemon.wait_for_log(r'Holding onto an incoming htlc for 10 seconds') l2.daemon.wait_for_log(r'Holding onto an incoming htlc for 10 seconds')
@@ -2054,7 +2054,7 @@ def test_3847_repro(node_factory, bitcoind):
amt = 20 * 1000 * 1000 amt = 20 * 1000 * 1000
i1 = l3.rpc.invoice( i1 = l3.rpc.invoice(
msatoshi=amt, label="direct", description="desc" amount_msat=amt, label="direct", description="desc"
)['bolt11'] )['bolt11']
with pytest.raises(RpcError): with pytest.raises(RpcError):
l1.rpc.pay(i1, retry_for=10) l1.rpc.pay(i1, retry_for=10)