Skip to content

Commit

Permalink
lightningd: change msatoshi args to amount_msat.
Browse files Browse the repository at this point in the history
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`)
  • Loading branch information
rustyrussell committed Jun 20, 2022
1 parent ca69e29 commit cd7e784
Show file tree
Hide file tree
Showing 25 changed files with 192 additions and 154 deletions.
7 changes: 7 additions & 0 deletions .msggen.json
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@
"Getinfo.warning_lightningd_sync": 17
},
"GetrouteRequest": {
"GetRoute.amount_msat": 9,
"GetRoute.cltv": 4,
"GetRoute.exclude[]": 7,
"GetRoute.fromid": 5,
Expand All @@ -464,6 +465,7 @@
"GetRoute.route[].style": 6
},
"InvoiceRequest": {
"Invoice.amount_msat": 10,
"Invoice.cltv": 6,
"Invoice.deschashonly": 9,
"Invoice.description": 2,
Expand All @@ -486,6 +488,7 @@
"Invoice.warning_private_unused": 8
},
"KeysendRequest": {
"KeySend.amount_msat": 10,
"KeySend.destination": 1,
"KeySend.exemptfee": 7,
"KeySend.extratlvs": 9,
Expand Down Expand Up @@ -821,6 +824,7 @@
"NewAddr.p2sh-segwit": 2
},
"PayRequest": {
"Pay.amount_msat": 13,
"Pay.bolt11": 1,
"Pay.description": 12,
"Pay.exclude": 10,
Expand Down Expand Up @@ -859,6 +863,7 @@
"SendOnion.first_hop.id": 1
},
"SendonionRequest": {
"SendOnion.amount_msat": 12,
"SendOnion.bolt11": 7,
"SendOnion.destination": 9,
"SendOnion.first_hop": 2,
Expand Down Expand Up @@ -887,6 +892,7 @@
"SendOnion.status": 3
},
"SendpayRequest": {
"SendPay.amount_msat": 10,
"SendPay.bolt11": 5,
"SendPay.groupid": 9,
"SendPay.label": 3,
Expand Down Expand Up @@ -914,6 +920,7 @@
"SendPay.status": 4
},
"SendpayRoute": {
"SendPay.route[].amount_msat": 5,
"SendPay.route[].channel": 4,
"SendPay.route[].delay": 3,
"SendPay.route[].id": 2,
Expand Down
14 changes: 7 additions & 7 deletions cln-grpc/proto/node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ message SendpayRequest {
repeated SendpayRoute route = 1;
bytes payment_hash = 2;
optional string label = 3;
optional Amount msatoshi = 4;
optional Amount amount_msat = 10;
optional string bolt11 = 5;
optional bytes payment_secret = 6;
optional uint32 partid = 7;
Expand Down Expand Up @@ -322,7 +322,7 @@ message SendpayResponse {
}

message SendpayRoute {
Amount msatoshi = 1;
optional Amount amount_msat = 5;
bytes id = 2;
uint32 delay = 3;
string channel = 4;
Expand Down Expand Up @@ -559,7 +559,7 @@ message DelinvoiceResponse {
}

message InvoiceRequest {
AmountOrAny msatoshi = 1;
AmountOrAny amount_msat = 10;
string description = 2;
string label = 3;
optional uint64 expiry = 7;
Expand Down Expand Up @@ -638,7 +638,7 @@ message SendonionRequest {
repeated bytes shared_secrets = 5;
optional uint32 partid = 6;
optional string bolt11 = 7;
optional Amount msatoshi = 8;
optional Amount amount_msat = 12;
optional bytes destination = 9;
optional bytes localofferid = 10;
optional uint64 groupid = 11;
Expand Down Expand Up @@ -775,7 +775,7 @@ message ListtransactionsTransactionsOutputs {

message PayRequest {
string bolt11 = 1;
optional Amount msatoshi = 2;
optional Amount amount_msat = 13;
optional string label = 3;
optional double riskfactor = 8;
optional double maxfeepercent = 4;
Expand Down Expand Up @@ -945,7 +945,7 @@ message WithdrawResponse {

message KeysendRequest {
bytes destination = 1;
Amount msatoshi = 2;
Amount amount_msat = 10;
optional string label = 3;
optional double maxfeepercent = 4;
optional uint32 retry_for = 5;
Expand Down Expand Up @@ -1134,7 +1134,7 @@ message FeeratesOnchain_fee_estimates {

message GetrouteRequest {
bytes id = 1;
Amount msatoshi = 2;
Amount amount_msat = 9;
uint64 riskfactor = 3;
optional double cltv = 4;
optional bytes fromid = 5;
Expand Down
14 changes: 7 additions & 7 deletions cln-grpc/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ impl From<&pb::ListfundsRequest> for requests::ListfundsRequest {
impl From<&pb::SendpayRoute> for requests::SendpayRoute {
fn from(c: &pb::SendpayRoute) -> 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
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
Expand All @@ -995,7 +995,7 @@ impl From<&pb::SendpayRequest> for requests::SendpayRequest {
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
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?
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?
Expand Down Expand Up @@ -1152,7 +1152,7 @@ impl From<&pb::DelinvoiceRequest> for requests::DelinvoiceRequest {
impl From<&pb::InvoiceRequest> for requests::InvoiceRequest {
fn from(c: &pb::InvoiceRequest) -> 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
label: c.label.clone(), // Rule #1 for type string
expiry: c.expiry.clone(), // Rule #1 for type u64?
Expand Down Expand Up @@ -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
partid: c.partid.map(|v| v as u16), // Rule #1 for type u16?
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?
localofferid: c.localofferid.clone().map(|v| v.try_into().unwrap()), // Rule #1 for type hash?
groupid: c.groupid.clone(), // Rule #1 for type u64?
Expand Down Expand Up @@ -1228,7 +1228,7 @@ impl From<&pb::PayRequest> for requests::PayRequest {
fn from(c: &pb::PayRequest) -> Self {
Self {
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?
riskfactor: c.riskfactor.clone(), // Rule #1 for type number?
maxfeepercent: c.maxfeepercent.clone(), // Rule #1 for type number?
Expand Down Expand Up @@ -1310,7 +1310,7 @@ impl From<&pb::KeysendRequest> for requests::KeysendRequest {
fn from(c: &pb::KeysendRequest) -> Self {
Self {
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?
maxfeepercent: c.maxfeepercent.clone(), // Rule #1 for type number?
retry_for: c.retry_for.clone(), // Rule #1 for type u32?
Expand Down Expand Up @@ -1428,7 +1428,7 @@ impl From<&pb::GetrouteRequest> for requests::GetrouteRequest {
fn from(c: &pb::GetrouteRequest) -> Self {
Self {
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
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?
Expand Down
28 changes: 14 additions & 14 deletions cln-rpc/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ pub mod requests {

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SendpayRoute {
#[serde(alias = "msatoshi")]
pub msatoshi: Amount,
#[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")]
pub amount_msat: Option<Amount>,
#[serde(alias = "id")]
pub id: Pubkey,
#[serde(alias = "delay")]
Expand All @@ -156,8 +156,8 @@ pub mod requests {
pub payment_hash: Sha256,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")]
pub label: Option<String>,
#[serde(alias = "msatoshi", skip_serializing_if = "Option::is_none")]
pub msatoshi: Option<Amount>,
#[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")]
pub amount_msat: Option<Amount>,
#[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")]
pub bolt11: Option<String>,
#[serde(alias = "payment_secret", skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -351,8 +351,8 @@ pub mod requests {

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

0 comments on commit cd7e784

Please sign in to comment.