diff --git a/.msggen.json b/.msggen.json index a9475fb0dfbf..cf166ea61c9e 100644 --- a/.msggen.json +++ b/.msggen.json @@ -33,6 +33,10 @@ "paid": 0, "unpaid": 2 }, + "FeeratesStyle": { + "perkb": 0, + "perkw": 1 + }, "GetinfoAddressType": { "dns": 0, "ipv4": 1, @@ -48,9 +52,28 @@ "torv2": 3, "torv3": 4 }, + "GetrouteRouteStyle": { + "tlv": 0 + }, "KeysendStatus": { "complete": 0 }, + "ListforwardsForwardsStatus": { + "failed": 3, + "local_failed": 2, + "offered": 0, + "settled": 1 + }, + "ListforwardsForwardsStyle": { + "legacy": 0, + "tlv": 1 + }, + "ListforwardsStatus": { + "failed": 3, + "local_failed": 2, + "offered": 0, + "settled": 1 + }, "ListfundsOutputsStatus": { "confirmed": 1, "spent": 2, @@ -69,6 +92,16 @@ "torv3": 4, "websocket": 5 }, + "ListpaysPaysStatus": { + "complete": 2, + "failed": 1, + "pending": 0 + }, + "ListpaysStatus": { + "complete": 1, + "failed": 2, + "pending": 0 + }, "ListpeersPeersChannelsHtlcsDirection": { "in": 0, "out": 1 @@ -144,6 +177,7 @@ "withdraw": 2 }, "NewaddrAddresstype": { + "all": 2, "bech32": 0, "p2sh-segwit": 1 }, @@ -197,6 +231,7 @@ "CloseRequest": { "Close.destination": 3, "Close.fee_negotiation_step": 4, + "Close.feerange[]": 7, "Close.force_lease_closed": 6, "Close.id": 1, "Close.unilateraltimeout": 2, @@ -262,22 +297,27 @@ "DatastoreRequest": { "Datastore.generation": 4, "Datastore.hex": 2, + "Datastore.key": 5, "Datastore.key[]": 1, - "Datastore.mode": 3 + "Datastore.mode": 3, + "Datastore.string": 6 }, "DatastoreResponse": { "Datastore.generation": 2, "Datastore.hex": 3, + "Datastore.key": 5, "Datastore.key[]": 1, "Datastore.string": 4 }, "DeldatastoreRequest": { "DelDatastore.generation": 2, + "DelDatastore.key": 3, "DelDatastore.key[]": 1 }, "DeldatastoreResponse": { "DelDatastore.generation": 2, "DelDatastore.hex": 3, + "DelDatastore.key": 5, "DelDatastore.key[]": 1, "DelDatastore.string": 4 }, @@ -285,6 +325,7 @@ "DelExpiredInvoice.maxexpirytime": 1 }, "DelinvoiceRequest": { + "DelInvoice.desconly": 3, "DelInvoice.label": 1, "DelInvoice.status": 2 }, @@ -300,7 +341,48 @@ "DelInvoice.payment_hash": 6, "DelInvoice.status": 7 }, + "DisconnectRequest": { + "Disconnect.force": 2, + "Disconnect.id": 1 + }, + "FeeratesOnchain_fee_estimates": { + "Feerates.onchain_fee_estimates.htlc_success_satoshis": 5, + "Feerates.onchain_fee_estimates.htlc_timeout_satoshis": 4, + "Feerates.onchain_fee_estimates.mutual_close_satoshis": 2, + "Feerates.onchain_fee_estimates.opening_channel_satoshis": 1, + "Feerates.onchain_fee_estimates.unilateral_close_satoshis": 3 + }, + "FeeratesPerkb": { + "Feerates.perkb.delayed_to_us": 6, + "Feerates.perkb.htlc_resolution": 7, + "Feerates.perkb.max_acceptable": 2, + "Feerates.perkb.min_acceptable": 1, + "Feerates.perkb.mutual_close": 4, + "Feerates.perkb.opening": 3, + "Feerates.perkb.penalty": 8, + "Feerates.perkb.unilateral_close": 5 + }, + "FeeratesPerkw": { + "Feerates.perkw.delayed_to_us": 6, + "Feerates.perkw.htlc_resolution": 7, + "Feerates.perkw.max_acceptable": 2, + "Feerates.perkw.min_acceptable": 1, + "Feerates.perkw.mutual_close": 4, + "Feerates.perkw.opening": 3, + "Feerates.perkw.penalty": 8, + "Feerates.perkw.unilateral_close": 5 + }, + "FeeratesRequest": { + "Feerates.style": 1 + }, + "FeeratesResponse": { + "Feerates.onchain_fee_estimates": 4, + "Feerates.perkb": 2, + "Feerates.perkw": 3, + "Feerates.warning_missing_feerates": 1 + }, "FundpsbtRequest": { + "FundPsbt.excess_as_change": 8, "FundPsbt.feerate": 2, "FundPsbt.locktime": 6, "FundPsbt.min_witness_weight": 7, @@ -360,9 +442,33 @@ "Getinfo.warning_bitcoind_sync": 16, "Getinfo.warning_lightningd_sync": 17 }, + "GetrouteRequest": { + "GetRoute.cltv": 4, + "GetRoute.exclude[]": 7, + "GetRoute.fromid": 5, + "GetRoute.fuzzpercent": 6, + "GetRoute.id": 1, + "GetRoute.maxhops": 8, + "GetRoute.msatoshi": 2, + "GetRoute.riskfactor": 3 + }, + "GetrouteResponse": { + "GetRoute.route[]": 1 + }, + "GetrouteRoute": { + "GetRoute.route[].amount_msat": 4, + "GetRoute.route[].channel": 2, + "GetRoute.route[].delay": 5, + "GetRoute.route[].direction": 3, + "GetRoute.route[].id": 1, + "GetRoute.route[].style": 6 + }, "InvoiceRequest": { "Invoice.cltv": 6, + "Invoice.deschashonly": 9, "Invoice.description": 2, + "Invoice.expiry": 7, + "Invoice.exposeprivatechannels": 8, "Invoice.fallbacks[]": 4, "Invoice.label": 3, "Invoice.msatoshi": 1, @@ -382,11 +488,13 @@ "KeysendRequest": { "KeySend.destination": 1, "KeySend.exemptfee": 7, + "KeySend.extratlvs": 9, "KeySend.label": 3, "KeySend.maxdelay": 6, "KeySend.maxfeepercent": 4, "KeySend.msatoshi": 2, - "KeySend.retry_for": 5 + "KeySend.retry_for": 5, + "KeySend.routehints": 8 }, "KeysendResponse": { "KeySend.amount_msat": 6, @@ -431,11 +539,31 @@ "ListDatastore.datastore[].string": 4 }, "ListdatastoreRequest": { + "ListDatastore.key": 2, "ListDatastore.key[]": 1 }, "ListdatastoreResponse": { "ListDatastore.datastore[]": 1 }, + "ListforwardsForwards": { + "ListForwards.forwards[].fee_msat": 7, + "ListForwards.forwards[].in_channel": 1, + "ListForwards.forwards[].in_msat": 2, + "ListForwards.forwards[].out_channel": 5, + "ListForwards.forwards[].out_msat": 8, + "ListForwards.forwards[].payment_hash": 6, + "ListForwards.forwards[].received_time": 4, + "ListForwards.forwards[].status": 3, + "ListForwards.forwards[].style": 9 + }, + "ListforwardsRequest": { + "ListForwards.in_channel": 2, + "ListForwards.out_channel": 3, + "ListForwards.status": 1 + }, + "ListforwardsResponse": { + "ListForwards.forwards[]": 1 + }, "ListfundsChannels": { "ListFunds.channels[].amount_msat": 3, "ListFunds.channels[].connected": 6, @@ -507,6 +635,26 @@ "ListnodesResponse": { "ListNodes.nodes[]": 1 }, + "ListpaysPays": { + "ListPays.pays[].amount_msat": 8, + "ListPays.pays[].amount_sent_msat": 9, + "ListPays.pays[].bolt11": 6, + "ListPays.pays[].bolt12": 7, + "ListPays.pays[].created_at": 4, + "ListPays.pays[].destination": 3, + "ListPays.pays[].erroronion": 10, + "ListPays.pays[].label": 5, + "ListPays.pays[].payment_hash": 1, + "ListPays.pays[].status": 2 + }, + "ListpaysRequest": { + "ListPays.bolt11": 1, + "ListPays.payment_hash": 2, + "ListPays.status": 3 + }, + "ListpaysResponse": { + "ListPays.pays[]": 1 + }, "ListpeersPeers": { "ListPeers.peers[].channels[]": 4, "ListPeers.peers[].connected": 2, @@ -539,8 +687,10 @@ "ListPeers.peers[].channels[].max_accepted_htlcs": 35, "ListPeers.peers[].channels[].max_to_us_msat": 22, "ListPeers.peers[].channels[].max_total_htlc_in_msat": 27, + "ListPeers.peers[].channels[].maximum_htlc_out_msat": 49, "ListPeers.peers[].channels[].min_to_us_msat": 21, "ListPeers.peers[].channels[].minimum_htlc_in_msat": 32, + "ListPeers.peers[].channels[].minimum_htlc_out_msat": 48, "ListPeers.peers[].channels[].next_fee_step": 12, "ListPeers.peers[].channels[].next_feerate": 11, "ListPeers.peers[].channels[].opener": 16, @@ -668,8 +818,10 @@ }, "PayRequest": { "Pay.bolt11": 1, + "Pay.exclude": 10, "Pay.exemptfee": 7, "Pay.label": 3, + "Pay.localofferid": 9, "Pay.maxdelay": 6, "Pay.maxfeepercent": 4, "Pay.msatoshi": 2, @@ -687,14 +839,31 @@ "Pay.status": 9, "Pay.warning_partial_completion": 8 }, + "PingRequest": { + "Ping.id": 1, + "Ping.len": 2, + "Ping.pongbytes": 3 + }, + "PingResponse": { + "Ping.totlen": 1 + }, "SendonionFirst_hop": { "SendOnion.first_hop.amount_msat": 2, "SendOnion.first_hop.delay": 3, "SendOnion.first_hop.id": 1 }, "SendonionRequest": { + "SendOnion.bolt11": 7, + "SendOnion.destination": 9, "SendOnion.first_hop": 2, - "SendOnion.onion": 1 + "SendOnion.groupid": 11, + "SendOnion.label": 4, + "SendOnion.localofferid": 10, + "SendOnion.msatoshi": 8, + "SendOnion.onion": 1, + "SendOnion.partid": 6, + "SendOnion.payment_hash": 3, + "SendOnion.shared_secrets[]": 5 }, "SendonionResponse": { "SendOnion.amount_msat": 4, @@ -706,13 +875,16 @@ "SendOnion.id": 1, "SendOnion.label": 8, "SendOnion.message": 12, + "SendOnion.partid": 13, "SendOnion.payment_hash": 2, "SendOnion.payment_preimage": 11, "SendOnion.status": 3 }, "SendpayRequest": { "SendPay.bolt11": 5, + "SendPay.groupid": 9, "SendPay.label": 3, + "SendPay.localofferid": 8, "SendPay.msatoshi": 4, "SendPay.partid": 7, "SendPay.payment_hash": 2, @@ -742,12 +914,21 @@ "SendPay.route[].msatoshi": 1 }, "SendpsbtRequest": { - "SendPsbt.psbt": 1 + "SendPsbt.psbt": 1, + "SendPsbt.reserve": 2 }, "SendpsbtResponse": { "SendPsbt.tx": 1, "SendPsbt.txid": 2 }, + "SignmessageRequest": { + "SignMessage.message": 1 + }, + "SignmessageResponse": { + "SignMessage.recid": 2, + "SignMessage.signature": 1, + "SignMessage.zbase": 3 + }, "SignpsbtRequest": { "SignPsbt.psbt": 1, "SignPsbt.signonly[]": 2 @@ -766,6 +947,7 @@ "TxPrepare.feerate": 2, "TxPrepare.minconf": 3, "TxPrepare.outptus[]": 1, + "TxPrepare.outputs[]": 5, "TxPrepare.utxos[]": 4 }, "TxprepareResponse": { @@ -782,10 +964,12 @@ "TxSend.txid": 3 }, "UtxopsbtRequest": { + "UtxoPsbt.excess_as_change": 9, "UtxoPsbt.feerate": 2, "UtxoPsbt.locktime": 6, "UtxoPsbt.min_witness_weight": 7, "UtxoPsbt.reserve": 5, + "UtxoPsbt.reservedok": 8, "UtxoPsbt.satoshi": 1, "UtxoPsbt.startweight": 3, "UtxoPsbt.utxos[]": 4 @@ -841,6 +1025,7 @@ "WaitInvoice.status": 4 }, "WaitsendpayRequest": { + "WaitSendPay.groupid": 4, "WaitSendPay.partid": 2, "WaitSendPay.payment_hash": 1, "WaitSendPay.timeout": 3 diff --git a/cln-grpc/proto/node.proto b/cln-grpc/proto/node.proto index cfd390c23984..508acb24b9b4 100644 --- a/cln-grpc/proto/node.proto +++ b/cln-grpc/proto/node.proto @@ -45,6 +45,13 @@ service Node { rpc TxDiscard(TxdiscardRequest) returns (TxdiscardResponse) {} rpc TxPrepare(TxprepareRequest) returns (TxprepareResponse) {} rpc TxSend(TxsendRequest) returns (TxsendResponse) {} + rpc Disconnect(DisconnectRequest) returns (DisconnectResponse) {} + rpc Feerates(FeeratesRequest) returns (FeeratesResponse) {} + rpc GetRoute(GetrouteRequest) returns (GetrouteResponse) {} + rpc ListForwards(ListforwardsRequest) returns (ListforwardsResponse) {} + rpc ListPays(ListpaysRequest) returns (ListpaysResponse) {} + rpc Ping(PingRequest) returns (PingResponse) {} + rpc SignMessage(SignmessageRequest) returns (SignmessageResponse) {} } message GetinfoRequest { @@ -174,7 +181,6 @@ message ListpeersPeersChannels { optional bytes close_to = 14; optional bool private = 15; ChannelSide opener = 16; - optional ChannelSide closer = 17; repeated string features = 18; optional Amount to_us_msat = 20; optional Amount min_to_us_msat = 21; @@ -189,6 +195,8 @@ message ListpeersPeersChannels { optional Amount spendable_msat = 30; optional Amount receivable_msat = 31; optional Amount minimum_htlc_in_msat = 32; + optional Amount minimum_htlc_out_msat = 48; + optional Amount maximum_htlc_out_msat = 49; optional uint32 their_to_self_delay = 33; optional uint32 our_to_self_delay = 34; optional uint32 max_accepted_htlcs = 35; @@ -231,19 +239,6 @@ message ListpeersPeersChannelsHtlcs { IN = 0; OUT = 1; } - // ListPeers.peers[].channels[].htlcs[].state - enum ListpeersPeersChannelsHtlcsState { - SENT_ADD_HTLC = 0; - SENT_ADD_COMMIT = 1; - RCVD_ADD_REVOCATION = 2; - RCVD_ADD_ACK_COMMIT = 3; - SENT_ADD_ACK_REVOCATION = 4; - RCVD_REMOVE_HTLC = 5; - RCVD_REMOVE_COMMIT = 6; - SENT_REMOVE_REVOCATION = 7; - SENT_REMOVE_ACK_COMMIT = 8; - RCVD_REMOVE_ACK_REVOCATION = 9; - } ListpeersPeersChannelsHtlcsDirection direction = 1; uint64 id = 2; Amount amount_msat = 3; @@ -251,7 +246,6 @@ message ListpeersPeersChannelsHtlcs { bytes payment_hash = 5; optional bool local_trimmed = 6; optional string status = 7; - ListpeersPeersChannelsHtlcsState state = 8; } message ListfundsRequest { @@ -299,6 +293,8 @@ message SendpayRequest { optional string bolt11 = 5; optional bytes payment_secret = 6; optional uint32 partid = 7; + optional bytes localofferid = 8; + optional uint64 groupid = 9; } message SendpayResponse { @@ -388,12 +384,13 @@ message CheckmessageResponse { } message CloseRequest { - bytes id = 1; + string id = 1; optional uint32 unilateraltimeout = 2; optional string destination = 3; optional string fee_negotiation_step = 4; optional bytes wrong_funding = 5; optional bool force_lease_closed = 6; + repeated Feerate feerange = 7; } message CloseResponse { @@ -409,7 +406,7 @@ message CloseResponse { } message ConnectRequest { - bytes id = 1; + string id = 1; optional string host = 2; optional uint32 port = 3; } @@ -478,14 +475,15 @@ message DatastoreRequest { MUST_APPEND = 3; CREATE_OR_APPEND = 4; } - repeated string key = 1; + repeated string key = 5; + optional string string = 6; optional bytes hex = 2; optional DatastoreMode mode = 3; optional uint64 generation = 4; } message DatastoreResponse { - repeated string key = 1; + repeated string key = 5; optional uint64 generation = 2; optional bytes hex = 3; optional string string = 4; @@ -509,19 +507,19 @@ message CreateonionHops { } message DeldatastoreRequest { - repeated string key = 1; + repeated string key = 3; optional uint64 generation = 2; } message DeldatastoreResponse { - repeated string key = 1; + repeated string key = 5; optional uint64 generation = 2; optional bytes hex = 3; optional string string = 4; } message DelexpiredinvoiceRequest { - uint32 maxexpirytime = 1; + optional uint64 maxexpirytime = 1; } message DelexpiredinvoiceResponse { @@ -536,6 +534,7 @@ message DelinvoiceRequest { } string label = 1; DelinvoiceStatus status = 2; + optional bool desconly = 3; } message DelinvoiceResponse { @@ -561,9 +560,12 @@ message InvoiceRequest { AmountOrAny msatoshi = 1; string description = 2; string label = 3; + optional uint64 expiry = 7; repeated string fallbacks = 4; optional bytes preimage = 5; + optional bool exposeprivatechannels = 8; optional uint32 cltv = 6; + optional bool deschashonly = 9; } message InvoiceResponse { @@ -579,7 +581,7 @@ message InvoiceResponse { } message ListdatastoreRequest { - repeated string key = 1; + repeated string key = 2; } message ListdatastoreResponse { @@ -612,7 +614,7 @@ message ListinvoicesInvoices { EXPIRED = 2; } string label = 1; - string description = 2; + optional string description = 2; bytes payment_hash = 3; ListinvoicesInvoicesStatus status = 4; uint64 expires_at = 5; @@ -629,6 +631,15 @@ message ListinvoicesInvoices { message SendonionRequest { bytes onion = 1; + bytes payment_hash = 3; + optional string label = 4; + repeated bytes shared_secrets = 5; + optional uint32 partid = 6; + optional string bolt11 = 7; + optional Amount msatoshi = 8; + optional bytes destination = 9; + optional bytes localofferid = 10; + optional uint64 groupid = 11; } message SendonionResponse { @@ -647,6 +658,7 @@ message SendonionResponse { optional string label = 8; optional string bolt11 = 9; optional string bolt12 = 10; + optional uint64 partid = 13; optional bytes payment_preimage = 11; optional string message = 12; } @@ -762,11 +774,13 @@ message PayRequest { string bolt11 = 1; optional Amount msatoshi = 2; optional string label = 3; - optional float riskfactor = 8; - optional float maxfeepercent = 4; + optional double riskfactor = 8; + optional double maxfeepercent = 4; optional uint32 retry_for = 5; optional uint32 maxdelay = 6; - optional float exemptfee = 7; + optional Amount exemptfee = 7; + optional bytes localofferid = 9; + repeated string exclude = 10; } message PayResponse { @@ -779,7 +793,7 @@ message PayResponse { bytes payment_preimage = 1; optional bytes destination = 2; bytes payment_hash = 3; - sint64 created_at = 4; + double created_at = 4; uint32 parts = 5; Amount amount_msat = 6; Amount amount_sent_msat = 7; @@ -820,8 +834,8 @@ message ListnodesNodesAddresses { } message WaitanyinvoiceRequest { - optional sint64 lastpay_index = 1; - optional sint64 timeout = 2; + optional uint64 lastpay_index = 1; + optional uint64 timeout = 2; } message WaitanyinvoiceResponse { @@ -870,8 +884,9 @@ message WaitinvoiceResponse { message WaitsendpayRequest { bytes payment_hash = 1; - optional uint32 partid = 2; optional uint32 timeout = 3; + optional uint64 partid = 2; + optional uint64 groupid = 4; } message WaitsendpayResponse { @@ -899,6 +914,7 @@ message NewaddrRequest { enum NewaddrAddresstype { BECH32 = 0; P2SH_SEGWIT = 1; + ALL = 2; } optional NewaddrAddresstype addresstype = 1; } @@ -909,11 +925,11 @@ message NewaddrResponse { } message WithdrawRequest { - bytes destination = 1; + string destination = 1; optional AmountOrAll satoshi = 2; optional Feerate feerate = 5; optional uint32 minconf = 3; - repeated Utxo utxos = 4; + repeated Outpoint utxos = 4; } message WithdrawResponse { @@ -926,10 +942,11 @@ message KeysendRequest { bytes destination = 1; Amount msatoshi = 2; optional string label = 3; - optional float maxfeepercent = 4; - optional sint64 retry_for = 5; - optional sint64 maxdelay = 6; + optional double maxfeepercent = 4; + optional uint32 retry_for = 5; + optional uint32 maxdelay = 6; optional Amount exemptfee = 7; + optional RoutehintList routehints = 8; } message KeysendResponse { @@ -940,7 +957,7 @@ message KeysendResponse { bytes payment_preimage = 1; optional bytes destination = 2; bytes payment_hash = 3; - sint64 created_at = 4; + double created_at = 4; uint32 parts = 5; Amount amount_msat = 6; Amount amount_sent_msat = 7; @@ -948,14 +965,18 @@ message KeysendResponse { KeysendStatus status = 9; } +message KeysendExtratlvs { +} + message FundpsbtRequest { Amount satoshi = 1; Feerate feerate = 2; - sint64 startweight = 3; - optional sint64 minconf = 4; - optional sint64 reserve = 5; - optional sint64 locktime = 6; + uint32 startweight = 3; + optional uint32 minconf = 4; + optional uint32 reserve = 5; + optional uint32 locktime = 6; optional uint32 min_witness_weight = 7; + optional bool excess_as_change = 8; } message FundpsbtResponse { @@ -977,6 +998,7 @@ message FundpsbtReservations { message SendpsbtRequest { string psbt = 1; + optional bool reserve = 2; } message SendpsbtResponse { @@ -986,6 +1008,7 @@ message SendpsbtResponse { message SignpsbtRequest { string psbt = 1; + repeated uint32 signonly = 2; } message SignpsbtResponse { @@ -995,11 +1018,13 @@ message SignpsbtResponse { message UtxopsbtRequest { Amount satoshi = 1; Feerate feerate = 2; - sint64 startweight = 3; - repeated Utxo utxos = 4; - optional sint64 reserve = 5; - optional sint64 locktime = 6; + uint32 startweight = 3; + repeated Outpoint utxos = 4; + optional uint32 reserve = 5; + optional bool reservedok = 8; + optional uint32 locktime = 6; optional uint32 min_witness_weight = 7; + optional bool excess_as_change = 9; } message UtxopsbtResponse { @@ -1029,10 +1054,10 @@ message TxdiscardResponse { } message TxprepareRequest { - repeated OutputDesc outptus = 1; + repeated OutputDesc outputs = 5; optional Feerate feerate = 2; optional uint32 minconf = 3; - repeated Utxo utxos = 4; + repeated Outpoint utxos = 4; } message TxprepareResponse { @@ -1050,3 +1075,178 @@ message TxsendResponse { bytes tx = 2; bytes txid = 3; } + +message DisconnectRequest { + bytes id = 1; + optional bool force = 2; +} + +message DisconnectResponse { +} + +message FeeratesRequest { + // Feerates.style + enum FeeratesStyle { + PERKB = 0; + PERKW = 1; + } + FeeratesStyle style = 1; +} + +message FeeratesResponse { + optional string warning_missing_feerates = 1; +} + +message FeeratesPerkb { + uint32 min_acceptable = 1; + uint32 max_acceptable = 2; + optional uint32 opening = 3; + optional uint32 mutual_close = 4; + optional uint32 unilateral_close = 5; + optional uint32 delayed_to_us = 6; + optional uint32 htlc_resolution = 7; + optional uint32 penalty = 8; +} + +message FeeratesPerkw { + uint32 min_acceptable = 1; + uint32 max_acceptable = 2; + optional uint32 opening = 3; + optional uint32 mutual_close = 4; + optional uint32 unilateral_close = 5; + optional uint32 delayed_to_us = 6; + optional uint32 htlc_resolution = 7; + optional uint32 penalty = 8; +} + +message FeeratesOnchain_fee_estimates { + uint64 opening_channel_satoshis = 1; + uint64 mutual_close_satoshis = 2; + uint64 unilateral_close_satoshis = 3; + uint64 htlc_timeout_satoshis = 4; + uint64 htlc_success_satoshis = 5; +} + +message GetrouteRequest { + bytes id = 1; + Amount msatoshi = 2; + uint64 riskfactor = 3; + optional double cltv = 4; + optional bytes fromid = 5; + optional uint32 fuzzpercent = 6; + repeated string exclude = 7; + optional uint32 maxhops = 8; +} + +message GetrouteResponse { + repeated GetrouteRoute route = 1; +} + +message GetrouteRoute { + // GetRoute.route[].style + enum GetrouteRouteStyle { + TLV = 0; + } + bytes id = 1; + string channel = 2; + uint32 direction = 3; + Amount amount_msat = 4; + uint32 delay = 5; + GetrouteRouteStyle style = 6; +} + +message ListforwardsRequest { + // ListForwards.status + enum ListforwardsStatus { + OFFERED = 0; + SETTLED = 1; + LOCAL_FAILED = 2; + FAILED = 3; + } + optional ListforwardsStatus status = 1; + optional string in_channel = 2; + optional string out_channel = 3; +} + +message ListforwardsResponse { + repeated ListforwardsForwards forwards = 1; +} + +message ListforwardsForwards { + // ListForwards.forwards[].status + enum ListforwardsForwardsStatus { + OFFERED = 0; + SETTLED = 1; + LOCAL_FAILED = 2; + FAILED = 3; + } + // ListForwards.forwards[].style + enum ListforwardsForwardsStyle { + LEGACY = 0; + TLV = 1; + } + string in_channel = 1; + Amount in_msat = 2; + ListforwardsForwardsStatus status = 3; + double received_time = 4; + optional string out_channel = 5; + optional bytes payment_hash = 6; + optional ListforwardsForwardsStyle style = 9; + optional Amount fee_msat = 7; + optional Amount out_msat = 8; +} + +message ListpaysRequest { + // ListPays.status + enum ListpaysStatus { + PENDING = 0; + COMPLETE = 1; + FAILED = 2; + } + optional string bolt11 = 1; + optional bytes payment_hash = 2; + optional ListpaysStatus status = 3; +} + +message ListpaysResponse { + repeated ListpaysPays pays = 1; +} + +message ListpaysPays { + // ListPays.pays[].status + enum ListpaysPaysStatus { + PENDING = 0; + FAILED = 1; + COMPLETE = 2; + } + bytes payment_hash = 1; + ListpaysPaysStatus status = 2; + optional bytes destination = 3; + uint64 created_at = 4; + optional string label = 5; + optional string bolt11 = 6; + optional string bolt12 = 7; + optional Amount amount_msat = 8; + optional Amount amount_sent_msat = 9; + optional bytes erroronion = 10; +} + +message PingRequest { + bytes id = 1; + optional double len = 2; + optional double pongbytes = 3; +} + +message PingResponse { + uint32 totlen = 1; +} + +message SignmessageRequest { + string message = 1; +} + +message SignmessageResponse { + bytes signature = 1; + bytes recid = 2; + string zbase = 3; +} diff --git a/cln-grpc/src/convert.rs b/cln-grpc/src/convert.rs index cb7d8d54bc5f..c09d559332a8 100644 --- a/cln-grpc/src/convert.rs +++ b/cln-grpc/src/convert.rs @@ -7,6 +7,7 @@ use std::convert::From; #[allow(unused_imports)] use cln_rpc::model::{responses,requests}; use crate::pb; +use std::str::FromStr; #[allow(unused_variables)] impl From<&responses::GetinfoAddress> for pb::GetinfoAddress { @@ -35,7 +36,7 @@ impl From<&responses::GetinfoBinding> for pb::GetinfoBinding { impl From<&responses::GetinfoResponse> for pb::GetinfoResponse { fn from(c: &responses::GetinfoResponse) -> Self { Self { - id: hex::decode(&c.id).unwrap(), // Rule #2 for type pubkey + id: c.id.to_vec(), // Rule #2 for type pubkey alias: c.alias.clone(), // Rule #2 for type string color: hex::decode(&c.color).unwrap(), // Rule #2 for type hex num_peers: c.num_peers.clone(), // Rule #2 for type u32 @@ -47,8 +48,8 @@ impl From<&responses::GetinfoResponse> for pb::GetinfoResponse { blockheight: c.blockheight.clone(), // Rule #2 for type u32 network: c.network.clone(), // Rule #2 for type string fees_collected_msat: Some(c.fees_collected_msat.into()), // Rule #2 for type msat - address: c.address.iter().map(|i| i.into()).collect(), - binding: c.binding.iter().map(|i| i.into()).collect(), + address: c.address.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + binding: c.binding.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 warning_bitcoind_sync: c.warning_bitcoind_sync.clone(), // Rule #2 for type string? warning_lightningd_sync: c.warning_lightningd_sync.clone(), // Rule #2 for type string? } @@ -64,7 +65,7 @@ impl From<&responses::ListpeersPeersLog> for pb::ListpeersPeersLog { time: c.time.clone(), // Rule #2 for type string? source: c.source.clone(), // Rule #2 for type string? log: c.log.clone(), // Rule #2 for type string? - node_id: c.node_id.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type pubkey? + node_id: c.node_id.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? data: c.data.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? } } @@ -92,10 +93,9 @@ impl From<&responses::ListpeersPeersChannelsHtlcs> for pb::ListpeersPeersChannel id: c.id.clone(), // Rule #2 for type u64 amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat expiry: c.expiry.clone(), // Rule #2 for type u32 - payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex + payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash local_trimmed: c.local_trimmed.clone(), // Rule #2 for type boolean? status: c.status.clone(), // Rule #2 for type string? - state: c.state as i32, } } } @@ -107,20 +107,19 @@ impl From<&responses::ListpeersPeersChannels> for pb::ListpeersPeersChannels { state: c.state as i32, scratch_txid: c.scratch_txid.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type txid? owner: c.owner.clone(), // Rule #2 for type string? - short_channel_id: c.short_channel_id.clone(), // Rule #2 for type short_channel_id? - channel_id: c.channel_id.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + short_channel_id: c.short_channel_id.as_ref().map(|v| v.to_string()), // Rule #2 for type short_channel_id? + channel_id: c.channel_id.clone().map(|v| v.to_vec()), // Rule #2 for type hash? funding_txid: c.funding_txid.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type txid? funding_outnum: c.funding_outnum.clone(), // Rule #2 for type u32? initial_feerate: c.initial_feerate.clone(), // Rule #2 for type string? last_feerate: c.last_feerate.clone(), // Rule #2 for type string? next_feerate: c.next_feerate.clone(), // Rule #2 for type string? next_fee_step: c.next_fee_step.clone(), // Rule #2 for type u32? - inflight: c.inflight.iter().map(|i| i.into()).collect(), + inflight: c.inflight.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 close_to: c.close_to.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? private: c.private.clone(), // Rule #2 for type boolean? opener: c.opener as i32, - closer: c.closer.map(|v| v as i32), - features: c.features.iter().map(|i| i.into()).collect(), + features: c.features.iter().map(|i| i.into()).collect(), // Rule #3 for type ListpeersPeersChannelsFeatures to_us_msat: c.to_us_msat.map(|f| f.into()), // Rule #2 for type msat? min_to_us_msat: c.min_to_us_msat.map(|f| f.into()), // Rule #2 for type msat? max_to_us_msat: c.max_to_us_msat.map(|f| f.into()), // Rule #2 for type msat? @@ -134,10 +133,12 @@ impl From<&responses::ListpeersPeersChannels> for pb::ListpeersPeersChannels { spendable_msat: c.spendable_msat.map(|f| f.into()), // Rule #2 for type msat? receivable_msat: c.receivable_msat.map(|f| f.into()), // Rule #2 for type msat? minimum_htlc_in_msat: c.minimum_htlc_in_msat.map(|f| f.into()), // Rule #2 for type msat? + minimum_htlc_out_msat: c.minimum_htlc_out_msat.map(|f| f.into()), // Rule #2 for type msat? + maximum_htlc_out_msat: c.maximum_htlc_out_msat.map(|f| f.into()), // Rule #2 for type msat? their_to_self_delay: c.their_to_self_delay.clone(), // Rule #2 for type u32? our_to_self_delay: c.our_to_self_delay.clone(), // Rule #2 for type u32? max_accepted_htlcs: c.max_accepted_htlcs.clone(), // Rule #2 for type u32? - status: c.status.iter().map(|i| i.into()).collect(), + status: c.status.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 in_payments_offered: c.in_payments_offered.clone(), // Rule #2 for type u64? in_offered_msat: c.in_offered_msat.map(|f| f.into()), // Rule #2 for type msat? in_payments_fulfilled: c.in_payments_fulfilled.clone(), // Rule #2 for type u64? @@ -146,7 +147,7 @@ impl From<&responses::ListpeersPeersChannels> for pb::ListpeersPeersChannels { out_offered_msat: c.out_offered_msat.map(|f| f.into()), // Rule #2 for type msat? out_payments_fulfilled: c.out_payments_fulfilled.clone(), // Rule #2 for type u64? out_fulfilled_msat: c.out_fulfilled_msat.map(|f| f.into()), // Rule #2 for type msat? - htlcs: c.htlcs.iter().map(|i| i.into()).collect(), + htlcs: c.htlcs.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 close_to_addr: c.close_to_addr.clone(), // Rule #2 for type string? } } @@ -156,11 +157,11 @@ impl From<&responses::ListpeersPeersChannels> for pb::ListpeersPeersChannels { impl From<&responses::ListpeersPeers> for pb::ListpeersPeers { fn from(c: &responses::ListpeersPeers) -> Self { Self { - id: hex::decode(&c.id).unwrap(), // Rule #2 for type pubkey + id: c.id.to_vec(), // Rule #2 for type pubkey connected: c.connected.clone(), // Rule #2 for type boolean - log: c.log.iter().map(|i| i.into()).collect(), - channels: c.channels.iter().map(|i| i.into()).collect(), - netaddr: c.netaddr.iter().map(|i| i.into()).collect(), + log: c.log.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + channels: c.channels.iter().map(|i| i.into()).collect(), // Rule #3 for type ListpeersPeersChannels + netaddr: c.netaddr.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 features: c.features.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? } } @@ -170,7 +171,7 @@ impl From<&responses::ListpeersPeers> for pb::ListpeersPeers { impl From<&responses::ListpeersResponse> for pb::ListpeersResponse { fn from(c: &responses::ListpeersResponse) -> Self { Self { - peers: c.peers.iter().map(|i| i.into()).collect(), + peers: c.peers.iter().map(|i| i.into()).collect(), // Rule #3 for type ListpeersPeers } } } @@ -195,14 +196,14 @@ impl From<&responses::ListfundsOutputs> for pb::ListfundsOutputs { impl From<&responses::ListfundsChannels> for pb::ListfundsChannels { fn from(c: &responses::ListfundsChannels) -> Self { Self { - peer_id: hex::decode(&c.peer_id).unwrap(), // Rule #2 for type pubkey + peer_id: c.peer_id.to_vec(), // Rule #2 for type pubkey our_amount_msat: Some(c.our_amount_msat.into()), // Rule #2 for type msat amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat funding_txid: hex::decode(&c.funding_txid).unwrap(), // Rule #2 for type txid funding_output: c.funding_output.clone(), // Rule #2 for type u32 connected: c.connected.clone(), // Rule #2 for type boolean state: c.state as i32, - short_channel_id: c.short_channel_id.clone(), // Rule #2 for type short_channel_id? + short_channel_id: c.short_channel_id.as_ref().map(|v| v.to_string()), // Rule #2 for type short_channel_id? } } } @@ -211,8 +212,8 @@ impl From<&responses::ListfundsChannels> for pb::ListfundsChannels { impl From<&responses::ListfundsResponse> for pb::ListfundsResponse { fn from(c: &responses::ListfundsResponse) -> Self { Self { - outputs: c.outputs.iter().map(|i| i.into()).collect(), - channels: c.channels.iter().map(|i| i.into()).collect(), + outputs: c.outputs.iter().map(|i| i.into()).collect(), // Rule #3 for type ListfundsOutputs + channels: c.channels.iter().map(|i| i.into()).collect(), // Rule #3 for type ListfundsChannels } } } @@ -223,17 +224,17 @@ impl From<&responses::SendpayResponse> for pb::SendpayResponse { Self { id: c.id.clone(), // Rule #2 for type u64 groupid: c.groupid.clone(), // Rule #2 for type u64? - payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex + payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash status: c.status as i32, amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? - destination: c.destination.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type pubkey? + destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? created_at: c.created_at.clone(), // Rule #2 for type u64 amount_sent_msat: Some(c.amount_sent_msat.into()), // Rule #2 for type msat label: c.label.clone(), // Rule #2 for type string? partid: c.partid.clone(), // Rule #2 for type u64? bolt11: c.bolt11.clone(), // Rule #2 for type string? bolt12: c.bolt12.clone(), // Rule #2 for type string? - payment_preimage: c.payment_preimage.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? message: c.message.clone(), // Rule #2 for type string? } } @@ -243,9 +244,9 @@ impl From<&responses::SendpayResponse> for pb::SendpayResponse { impl From<&responses::ListchannelsChannels> for pb::ListchannelsChannels { fn from(c: &responses::ListchannelsChannels) -> Self { Self { - source: hex::decode(&c.source).unwrap(), // Rule #2 for type pubkey - destination: hex::decode(&c.destination).unwrap(), // Rule #2 for type pubkey - short_channel_id: c.short_channel_id.clone(), // Rule #2 for type short_channel_id + source: c.source.to_vec(), // Rule #2 for type pubkey + destination: c.destination.to_vec(), // Rule #2 for type pubkey + short_channel_id: c.short_channel_id.to_string(), // Rule #2 for type short_channel_id public: c.public.clone(), // Rule #2 for type boolean amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat message_flags: c.message_flags.into(), // Rule #2 for type u8 @@ -266,7 +267,7 @@ impl From<&responses::ListchannelsChannels> for pb::ListchannelsChannels { impl From<&responses::ListchannelsResponse> for pb::ListchannelsResponse { fn from(c: &responses::ListchannelsResponse) -> Self { Self { - channels: c.channels.iter().map(|i| i.into()).collect(), + channels: c.channels.iter().map(|i| i.into()).collect(), // Rule #3 for type ListchannelsChannels } } } @@ -295,7 +296,7 @@ impl From<&responses::CheckmessageResponse> for pb::CheckmessageResponse { fn from(c: &responses::CheckmessageResponse) -> Self { Self { verified: c.verified.clone(), // Rule #2 for type boolean - pubkey: c.pubkey.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type pubkey? + pubkey: c.pubkey.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? } } } @@ -315,7 +316,7 @@ impl From<&responses::CloseResponse> for pb::CloseResponse { impl From<&responses::ConnectResponse> for pb::ConnectResponse { fn from(c: &responses::ConnectResponse) -> Self { Self { - id: hex::decode(&c.id).unwrap(), // Rule #2 for type pubkey + id: c.id.to_vec(), // Rule #2 for type pubkey features: hex::decode(&c.features).unwrap(), // Rule #2 for type hex direction: c.direction as i32, } @@ -329,7 +330,7 @@ impl From<&responses::CreateinvoiceResponse> for pb::CreateinvoiceResponse { label: c.label.clone(), // Rule #2 for type string bolt11: c.bolt11.clone(), // Rule #2 for type string? bolt12: c.bolt12.clone(), // Rule #2 for type string? - payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex + payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? status: c.status as i32, description: c.description.clone(), // Rule #2 for type string @@ -337,7 +338,7 @@ impl From<&responses::CreateinvoiceResponse> for pb::CreateinvoiceResponse { pay_index: c.pay_index.clone(), // Rule #2 for type u64? amount_received_msat: c.amount_received_msat.map(|f| f.into()), // Rule #2 for type msat? paid_at: c.paid_at.clone(), // Rule #2 for type u64? - payment_preimage: c.payment_preimage.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? local_offer_id: c.local_offer_id.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? payer_note: c.payer_note.clone(), // Rule #2 for type string? } @@ -348,7 +349,7 @@ impl From<&responses::CreateinvoiceResponse> for pb::CreateinvoiceResponse { impl From<&responses::DatastoreResponse> for pb::DatastoreResponse { fn from(c: &responses::DatastoreResponse) -> Self { Self { - key: c.key.iter().map(|i| i.into()).collect(), + key: c.key.iter().map(|i| i.into()).collect(), // Rule #3 for type string generation: c.generation.clone(), // Rule #2 for type u64? hex: c.hex.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? string: c.string.clone(), // Rule #2 for type string? @@ -361,7 +362,7 @@ impl From<&responses::CreateonionResponse> for pb::CreateonionResponse { fn from(c: &responses::CreateonionResponse) -> Self { Self { onion: hex::decode(&c.onion).unwrap(), // Rule #2 for type hex - shared_secrets: c.shared_secrets.iter().map(|i| hex::decode(i).unwrap()).collect(), + shared_secrets: c.shared_secrets.iter().map(|i| i.clone().to_vec()).collect(), // Rule #3 for type secret } } } @@ -370,7 +371,7 @@ impl From<&responses::CreateonionResponse> for pb::CreateonionResponse { impl From<&responses::DeldatastoreResponse> for pb::DeldatastoreResponse { fn from(c: &responses::DeldatastoreResponse) -> Self { Self { - key: c.key.iter().map(|i| i.into()).collect(), + key: c.key.iter().map(|i| i.into()).collect(), // Rule #3 for type string generation: c.generation.clone(), // Rule #2 for type u64? hex: c.hex.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? string: c.string.clone(), // Rule #2 for type string? @@ -395,7 +396,7 @@ impl From<&responses::DelinvoiceResponse> for pb::DelinvoiceResponse { bolt12: c.bolt12.clone(), // Rule #2 for type string? amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? description: c.description.clone(), // Rule #2 for type string? - payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex + payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash status: c.status as i32, expires_at: c.expires_at.clone(), // Rule #2 for type u64 local_offer_id: c.local_offer_id.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? @@ -409,8 +410,8 @@ impl From<&responses::InvoiceResponse> for pb::InvoiceResponse { fn from(c: &responses::InvoiceResponse) -> Self { Self { bolt11: c.bolt11.clone(), // Rule #2 for type string - payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex - payment_secret: hex::decode(&c.payment_secret).unwrap(), // Rule #2 for type hex + payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash + payment_secret: c.payment_secret.clone().to_vec(), // Rule #2 for type secret expires_at: c.expires_at.clone(), // Rule #2 for type u64 warning_capacity: c.warning_capacity.clone(), // Rule #2 for type string? warning_offline: c.warning_offline.clone(), // Rule #2 for type string? @@ -425,7 +426,7 @@ impl From<&responses::InvoiceResponse> for pb::InvoiceResponse { impl From<&responses::ListdatastoreDatastore> for pb::ListdatastoreDatastore { fn from(c: &responses::ListdatastoreDatastore) -> Self { Self { - key: c.key.iter().map(|i| i.into()).collect(), + key: c.key.iter().map(|i| i.into()).collect(), // Rule #3 for type string generation: c.generation.clone(), // Rule #2 for type u64? hex: c.hex.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? string: c.string.clone(), // Rule #2 for type string? @@ -437,7 +438,7 @@ impl From<&responses::ListdatastoreDatastore> for pb::ListdatastoreDatastore { impl From<&responses::ListdatastoreResponse> for pb::ListdatastoreResponse { fn from(c: &responses::ListdatastoreResponse) -> Self { Self { - datastore: c.datastore.iter().map(|i| i.into()).collect(), + datastore: c.datastore.iter().map(|i| i.into()).collect(), // Rule #3 for type ListdatastoreDatastore } } } @@ -447,8 +448,8 @@ impl From<&responses::ListinvoicesInvoices> for pb::ListinvoicesInvoices { fn from(c: &responses::ListinvoicesInvoices) -> Self { Self { label: c.label.clone(), // Rule #2 for type string - description: c.description.clone(), // Rule #2 for type string - payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex + description: c.description.clone(), // Rule #2 for type string? + payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash status: c.status as i32, expires_at: c.expires_at.clone(), // Rule #2 for type u64 amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? @@ -459,7 +460,7 @@ impl From<&responses::ListinvoicesInvoices> for pb::ListinvoicesInvoices { pay_index: c.pay_index.clone(), // Rule #2 for type u64? amount_received_msat: c.amount_received_msat.map(|f| f.into()), // Rule #2 for type msat? paid_at: c.paid_at.clone(), // Rule #2 for type u64? - payment_preimage: c.payment_preimage.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? } } } @@ -468,7 +469,7 @@ impl From<&responses::ListinvoicesInvoices> for pb::ListinvoicesInvoices { impl From<&responses::ListinvoicesResponse> for pb::ListinvoicesResponse { fn from(c: &responses::ListinvoicesResponse) -> Self { Self { - invoices: c.invoices.iter().map(|i| i.into()).collect(), + invoices: c.invoices.iter().map(|i| i.into()).collect(), // Rule #3 for type ListinvoicesInvoices } } } @@ -478,16 +479,17 @@ impl From<&responses::SendonionResponse> for pb::SendonionResponse { fn from(c: &responses::SendonionResponse) -> Self { Self { id: c.id.clone(), // Rule #2 for type u64 - payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex + payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash status: c.status as i32, amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? - destination: c.destination.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type pubkey? + destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? created_at: c.created_at.clone(), // Rule #2 for type u64 amount_sent_msat: Some(c.amount_sent_msat.into()), // Rule #2 for type msat label: c.label.clone(), // Rule #2 for type string? bolt11: c.bolt11.clone(), // Rule #2 for type string? bolt12: c.bolt12.clone(), // Rule #2 for type string? - payment_preimage: c.payment_preimage.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + partid: c.partid.clone(), // Rule #2 for type u64? + payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? message: c.message.clone(), // Rule #2 for type string? } } @@ -499,16 +501,16 @@ impl From<&responses::ListsendpaysPayments> for pb::ListsendpaysPayments { Self { id: c.id.clone(), // Rule #2 for type u64 groupid: c.groupid.clone(), // Rule #2 for type u64? - payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex + payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash status: c.status as i32, amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? - destination: c.destination.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type pubkey? + destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? created_at: c.created_at.clone(), // Rule #2 for type u64 amount_sent_msat: Some(c.amount_sent_msat.into()), // Rule #2 for type msat label: c.label.clone(), // Rule #2 for type string? bolt11: c.bolt11.clone(), // Rule #2 for type string? bolt12: c.bolt12.clone(), // Rule #2 for type string? - payment_preimage: c.payment_preimage.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? erroronion: c.erroronion.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? } } @@ -518,7 +520,7 @@ impl From<&responses::ListsendpaysPayments> for pb::ListsendpaysPayments { impl From<&responses::ListsendpaysResponse> for pb::ListsendpaysResponse { fn from(c: &responses::ListsendpaysResponse) -> Self { Self { - payments: c.payments.iter().map(|i| i.into()).collect(), + payments: c.payments.iter().map(|i| i.into()).collect(), // Rule #3 for type ListsendpaysPayments } } } @@ -531,7 +533,7 @@ impl From<&responses::ListtransactionsTransactionsInputs> for pb::Listtransactio index: c.index.clone(), // Rule #2 for type u32 sequence: c.sequence.clone(), // Rule #2 for type u32 item_type: c.item_type.map(|v| v as i32), - channel: c.channel.clone(), // Rule #2 for type short_channel_id? + channel: c.channel.as_ref().map(|v| v.to_string()), // Rule #2 for type short_channel_id? } } } @@ -544,7 +546,7 @@ impl From<&responses::ListtransactionsTransactionsOutputs> for pb::Listtransacti msat: Some(c.msat.into()), // Rule #2 for type msat script_pub_key: hex::decode(&c.script_pub_key).unwrap(), // Rule #2 for type hex item_type: c.item_type.map(|v| v as i32), - channel: c.channel.clone(), // Rule #2 for type short_channel_id? + channel: c.channel.as_ref().map(|v| v.to_string()), // Rule #2 for type short_channel_id? } } } @@ -557,11 +559,11 @@ impl From<&responses::ListtransactionsTransactions> for pb::ListtransactionsTran rawtx: hex::decode(&c.rawtx).unwrap(), // Rule #2 for type hex blockheight: c.blockheight.clone(), // Rule #2 for type u32 txindex: c.txindex.clone(), // Rule #2 for type u32 - channel: c.channel.clone(), // Rule #2 for type short_channel_id? + channel: c.channel.as_ref().map(|v| v.to_string()), // Rule #2 for type short_channel_id? locktime: c.locktime.clone(), // Rule #2 for type u32 version: c.version.clone(), // Rule #2 for type u32 - inputs: c.inputs.iter().map(|i| i.into()).collect(), - outputs: c.outputs.iter().map(|i| i.into()).collect(), + inputs: c.inputs.iter().map(|i| i.into()).collect(), // Rule #3 for type ListtransactionsTransactionsInputs + outputs: c.outputs.iter().map(|i| i.into()).collect(), // Rule #3 for type ListtransactionsTransactionsOutputs } } } @@ -570,7 +572,7 @@ impl From<&responses::ListtransactionsTransactions> for pb::ListtransactionsTran impl From<&responses::ListtransactionsResponse> for pb::ListtransactionsResponse { fn from(c: &responses::ListtransactionsResponse) -> Self { Self { - transactions: c.transactions.iter().map(|i| i.into()).collect(), + transactions: c.transactions.iter().map(|i| i.into()).collect(), // Rule #3 for type ListtransactionsTransactions } } } @@ -579,9 +581,9 @@ impl From<&responses::ListtransactionsResponse> for pb::ListtransactionsResponse impl From<&responses::PayResponse> for pb::PayResponse { fn from(c: &responses::PayResponse) -> Self { Self { - payment_preimage: hex::decode(&c.payment_preimage).unwrap(), // Rule #2 for type hex - destination: c.destination.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type pubkey? - payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex + payment_preimage: c.payment_preimage.clone().to_vec(), // Rule #2 for type secret + destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? + payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash created_at: c.created_at.clone(), // Rule #2 for type number parts: c.parts.clone(), // Rule #2 for type u32 amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat @@ -607,12 +609,12 @@ impl From<&responses::ListnodesNodesAddresses> for pb::ListnodesNodesAddresses { impl From<&responses::ListnodesNodes> for pb::ListnodesNodes { fn from(c: &responses::ListnodesNodes) -> Self { Self { - nodeid: hex::decode(&c.nodeid).unwrap(), // Rule #2 for type pubkey + nodeid: c.nodeid.to_vec(), // Rule #2 for type pubkey last_timestamp: c.last_timestamp.clone(), // Rule #2 for type u32? alias: c.alias.clone(), // Rule #2 for type string? color: c.color.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? features: c.features.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? - addresses: c.addresses.iter().map(|i| i.into()).collect(), + addresses: c.addresses.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 } } } @@ -621,7 +623,7 @@ impl From<&responses::ListnodesNodes> for pb::ListnodesNodes { impl From<&responses::ListnodesResponse> for pb::ListnodesResponse { fn from(c: &responses::ListnodesResponse) -> Self { Self { - nodes: c.nodes.iter().map(|i| i.into()).collect(), + nodes: c.nodes.iter().map(|i| i.into()).collect(), // Rule #3 for type ListnodesNodes } } } @@ -632,7 +634,7 @@ impl From<&responses::WaitanyinvoiceResponse> for pb::WaitanyinvoiceResponse { Self { label: c.label.clone(), // Rule #2 for type string description: c.description.clone(), // Rule #2 for type string - payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex + payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash status: c.status as i32, expires_at: c.expires_at.clone(), // Rule #2 for type u64 amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? @@ -641,7 +643,7 @@ impl From<&responses::WaitanyinvoiceResponse> for pb::WaitanyinvoiceResponse { pay_index: c.pay_index.clone(), // Rule #2 for type u64? amount_received_msat: c.amount_received_msat.map(|f| f.into()), // Rule #2 for type msat? paid_at: c.paid_at.clone(), // Rule #2 for type u64? - payment_preimage: c.payment_preimage.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? } } } @@ -652,7 +654,7 @@ impl From<&responses::WaitinvoiceResponse> for pb::WaitinvoiceResponse { Self { label: c.label.clone(), // Rule #2 for type string description: c.description.clone(), // Rule #2 for type string - payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex + payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash status: c.status as i32, expires_at: c.expires_at.clone(), // Rule #2 for type u64 amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? @@ -661,7 +663,7 @@ impl From<&responses::WaitinvoiceResponse> for pb::WaitinvoiceResponse { pay_index: c.pay_index.clone(), // Rule #2 for type u64? amount_received_msat: c.amount_received_msat.map(|f| f.into()), // Rule #2 for type msat? paid_at: c.paid_at.clone(), // Rule #2 for type u64? - payment_preimage: c.payment_preimage.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? } } } @@ -672,17 +674,17 @@ impl From<&responses::WaitsendpayResponse> for pb::WaitsendpayResponse { Self { id: c.id.clone(), // Rule #2 for type u64 groupid: c.groupid.clone(), // Rule #2 for type u64? - payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex + payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash status: c.status as i32, amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? - destination: c.destination.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type pubkey? + destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? created_at: c.created_at.clone(), // Rule #2 for type u64 amount_sent_msat: Some(c.amount_sent_msat.into()), // Rule #2 for type msat label: c.label.clone(), // Rule #2 for type string? partid: c.partid.clone(), // Rule #2 for type u64? bolt11: c.bolt11.clone(), // Rule #2 for type string? bolt12: c.bolt12.clone(), // Rule #2 for type string? - payment_preimage: c.payment_preimage.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? } } } @@ -712,9 +714,9 @@ impl From<&responses::WithdrawResponse> for pb::WithdrawResponse { impl From<&responses::KeysendResponse> for pb::KeysendResponse { fn from(c: &responses::KeysendResponse) -> Self { Self { - payment_preimage: hex::decode(&c.payment_preimage).unwrap(), // Rule #2 for type hex - destination: c.destination.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type pubkey? - payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex + payment_preimage: c.payment_preimage.clone().to_vec(), // Rule #2 for type secret + destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? + payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash created_at: c.created_at.clone(), // Rule #2 for type number parts: c.parts.clone(), // Rule #2 for type u32 amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat @@ -747,7 +749,7 @@ impl From<&responses::FundpsbtResponse> for pb::FundpsbtResponse { estimated_final_weight: c.estimated_final_weight.clone(), // Rule #2 for type u32 excess_msat: Some(c.excess_msat.into()), // Rule #2 for type msat change_outnum: c.change_outnum.clone(), // Rule #2 for type u32? - reservations: c.reservations.iter().map(|i| i.into()).collect(), + reservations: c.reservations.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 } } } @@ -793,7 +795,7 @@ impl From<&responses::UtxopsbtResponse> for pb::UtxopsbtResponse { estimated_final_weight: c.estimated_final_weight.clone(), // Rule #2 for type u32 excess_msat: Some(c.excess_msat.into()), // Rule #2 for type msat change_outnum: c.change_outnum.clone(), // Rule #2 for type u32? - reservations: c.reservations.iter().map(|i| i.into()).collect(), + reservations: c.reservations.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 } } } @@ -830,6 +832,119 @@ impl From<&responses::TxsendResponse> for pb::TxsendResponse { } } +#[allow(unused_variables)] +impl From<&responses::DisconnectResponse> for pb::DisconnectResponse { + fn from(c: &responses::DisconnectResponse) -> Self { + Self { + } + } +} + +#[allow(unused_variables)] +impl From<&responses::FeeratesResponse> for pb::FeeratesResponse { + fn from(c: &responses::FeeratesResponse) -> Self { + Self { + warning_missing_feerates: c.warning_missing_feerates.clone(), // Rule #2 for type string? + } + } +} + +#[allow(unused_variables)] +impl From<&responses::GetrouteRoute> for pb::GetrouteRoute { + fn from(c: &responses::GetrouteRoute) -> Self { + Self { + id: c.id.to_vec(), // Rule #2 for type pubkey + channel: c.channel.to_string(), // Rule #2 for type short_channel_id + direction: c.direction.clone(), // Rule #2 for type u32 + amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat + delay: c.delay.clone(), // Rule #2 for type u32 + style: c.style as i32, + } + } +} + +#[allow(unused_variables)] +impl From<&responses::GetrouteResponse> for pb::GetrouteResponse { + fn from(c: &responses::GetrouteResponse) -> Self { + Self { + route: c.route.iter().map(|i| i.into()).collect(), // Rule #3 for type GetrouteRoute + } + } +} + +#[allow(unused_variables)] +impl From<&responses::ListforwardsForwards> for pb::ListforwardsForwards { + fn from(c: &responses::ListforwardsForwards) -> Self { + Self { + in_channel: c.in_channel.to_string(), // Rule #2 for type short_channel_id + in_msat: Some(c.in_msat.into()), // Rule #2 for type msat + status: c.status as i32, + received_time: c.received_time.clone(), // Rule #2 for type number + out_channel: c.out_channel.as_ref().map(|v| v.to_string()), // Rule #2 for type short_channel_id? + payment_hash: c.payment_hash.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + style: c.style.map(|v| v as i32), + fee_msat: c.fee_msat.map(|f| f.into()), // Rule #2 for type msat? + out_msat: c.out_msat.map(|f| f.into()), // Rule #2 for type msat? + } + } +} + +#[allow(unused_variables)] +impl From<&responses::ListforwardsResponse> for pb::ListforwardsResponse { + fn from(c: &responses::ListforwardsResponse) -> Self { + Self { + forwards: c.forwards.iter().map(|i| i.into()).collect(), // Rule #3 for type ListforwardsForwards + } + } +} + +#[allow(unused_variables)] +impl From<&responses::ListpaysPays> for pb::ListpaysPays { + fn from(c: &responses::ListpaysPays) -> Self { + Self { + payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex + status: c.status as i32, + destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? + created_at: c.created_at.clone(), // Rule #2 for type u64 + label: c.label.clone(), // Rule #2 for type string? + bolt11: c.bolt11.clone(), // Rule #2 for type string? + bolt12: c.bolt12.clone(), // Rule #2 for type string? + amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? + amount_sent_msat: c.amount_sent_msat.map(|f| f.into()), // Rule #2 for type msat? + erroronion: c.erroronion.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + } + } +} + +#[allow(unused_variables)] +impl From<&responses::ListpaysResponse> for pb::ListpaysResponse { + fn from(c: &responses::ListpaysResponse) -> Self { + Self { + pays: c.pays.iter().map(|i| i.into()).collect(), // Rule #3 for type ListpaysPays + } + } +} + +#[allow(unused_variables)] +impl From<&responses::PingResponse> for pb::PingResponse { + fn from(c: &responses::PingResponse) -> Self { + Self { + totlen: c.totlen.into(), // Rule #2 for type u16 + } + } +} + +#[allow(unused_variables)] +impl From<&responses::SignmessageResponse> for pb::SignmessageResponse { + fn from(c: &responses::SignmessageResponse) -> Self { + Self { + signature: hex::decode(&c.signature).unwrap(), // Rule #2 for type hex + recid: hex::decode(&c.recid).unwrap(), // Rule #2 for type hex + zbase: c.zbase.clone(), // Rule #2 for type string + } + } +} + #[allow(unused_variables)] impl From<&pb::GetinfoRequest> for requests::GetinfoRequest { fn from(c: &pb::GetinfoRequest) -> Self { @@ -842,7 +957,7 @@ impl From<&pb::GetinfoRequest> for requests::GetinfoRequest { impl From<&pb::ListpeersRequest> for requests::ListpeersRequest { fn from(c: &pb::ListpeersRequest) -> Self { Self { - id: c.id.clone().map(|v| hex::encode(v)), // Rule #1 for type pubkey? + id: c.id.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey? level: c.level.clone(), // Rule #1 for type string? } } @@ -862,9 +977,9 @@ 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 - id: hex::encode(&c.id), // 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 - channel: c.channel.clone(), // Rule #1 for type short_channel_id + channel: cln_rpc::primitives::ShortChannelId::from_str(&c.channel).unwrap(), // Rule #1 for type short_channel_id } } } @@ -873,13 +988,15 @@ impl From<&pb::SendpayRoute> for requests::SendpayRoute { impl From<&pb::SendpayRequest> for requests::SendpayRequest { fn from(c: &pb::SendpayRequest) -> Self { Self { - route: c.route.iter().map(|s| s.into()).collect(), - payment_hash: hex::encode(&c.payment_hash), // Rule #1 for type hex + 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? bolt11: c.bolt11.clone(), // Rule #1 for type string? - payment_secret: c.payment_secret.clone().map(|v| hex::encode(v)), // Rule #1 for type hex? + 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? + localofferid: c.localofferid.clone().map(|v| hex::encode(v)), // Rule #1 for type hex? + groupid: c.groupid.clone(), // Rule #1 for type u64? } } } @@ -888,9 +1005,9 @@ impl From<&pb::SendpayRequest> for requests::SendpayRequest { impl From<&pb::ListchannelsRequest> for requests::ListchannelsRequest { fn from(c: &pb::ListchannelsRequest) -> Self { Self { - short_channel_id: c.short_channel_id.clone(), // Rule #1 for type short_channel_id? - source: c.source.clone().map(|v| hex::encode(v)), // Rule #1 for type pubkey? - destination: c.destination.clone().map(|v| hex::encode(v)), // Rule #1 for type pubkey? + short_channel_id: c.short_channel_id.as_ref().map(|v| cln_rpc::primitives::ShortChannelId::from_str(&v).unwrap()), // Rule #1 for type short_channel_id? + source: c.source.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? } } } @@ -920,7 +1037,7 @@ impl From<&pb::CheckmessageRequest> for requests::CheckmessageRequest { Self { message: c.message.clone(), // Rule #1 for type string zbase: c.zbase.clone(), // Rule #1 for type string - pubkey: c.pubkey.clone().map(|v| hex::encode(v)), // Rule #1 for type pubkey? + pubkey: c.pubkey.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey? } } } @@ -929,12 +1046,13 @@ impl From<&pb::CheckmessageRequest> for requests::CheckmessageRequest { impl From<&pb::CloseRequest> for requests::CloseRequest { fn from(c: &pb::CloseRequest) -> Self { Self { - id: hex::encode(&c.id), // Rule #1 for type pubkey + id: c.id.clone(), // Rule #1 for type string unilateraltimeout: c.unilateraltimeout.clone(), // Rule #1 for type u32? destination: c.destination.clone(), // Rule #1 for type string? fee_negotiation_step: c.fee_negotiation_step.clone(), // Rule #1 for type string? wrong_funding: c.wrong_funding.clone().map(|v| hex::encode(v)), // Rule #1 for type txid? force_lease_closed: c.force_lease_closed.clone(), // Rule #1 for type boolean? + feerange: Some(c.feerange.iter().map(|s| s.into()).collect()), // Rule #4 } } } @@ -943,7 +1061,7 @@ impl From<&pb::CloseRequest> for requests::CloseRequest { impl From<&pb::ConnectRequest> for requests::ConnectRequest { fn from(c: &pb::ConnectRequest) -> Self { Self { - id: hex::encode(&c.id), // Rule #1 for type pubkey + id: c.id.clone(), // Rule #1 for type string host: c.host.clone(), // Rule #1 for type string? port: c.port.map(|v| v as u16), // Rule #1 for type u16? } @@ -965,7 +1083,8 @@ impl From<&pb::CreateinvoiceRequest> for requests::CreateinvoiceRequest { impl From<&pb::DatastoreRequest> for requests::DatastoreRequest { fn from(c: &pb::DatastoreRequest) -> Self { Self { - key: c.key.iter().map(|s| s.into()).collect(), + key: c.key.iter().map(|s| s.into()).collect(), // Rule #4 + string: c.string.clone(), // Rule #1 for type string? hex: c.hex.clone().map(|v| hex::encode(v)), // Rule #1 for type hex? mode: c.mode.map(|v| v.try_into().unwrap()), generation: c.generation.clone(), // Rule #1 for type u64? @@ -977,7 +1096,7 @@ impl From<&pb::DatastoreRequest> for requests::DatastoreRequest { impl From<&pb::CreateonionHops> for requests::CreateonionHops { fn from(c: &pb::CreateonionHops) -> Self { Self { - pubkey: hex::encode(&c.pubkey), // Rule #1 for type pubkey + pubkey: cln_rpc::primitives::Pubkey::from_slice(&c.pubkey).unwrap(), // Rule #1 for type pubkey payload: hex::encode(&c.payload), // Rule #1 for type hex } } @@ -987,9 +1106,9 @@ impl From<&pb::CreateonionHops> for requests::CreateonionHops { impl From<&pb::CreateonionRequest> for requests::CreateonionRequest { fn from(c: &pb::CreateonionRequest) -> Self { Self { - hops: c.hops.iter().map(|s| s.into()).collect(), + hops: c.hops.iter().map(|s| s.into()).collect(), // Rule #4 assocdata: hex::encode(&c.assocdata), // Rule #1 for type hex - session_key: c.session_key.clone().map(|v| hex::encode(v)), // Rule #1 for type hex? + session_key: c.session_key.clone().map(|v| v.try_into().unwrap()), // Rule #1 for type secret? onion_size: c.onion_size.map(|v| v as u16), // Rule #1 for type u16? } } @@ -999,7 +1118,7 @@ impl From<&pb::CreateonionRequest> for requests::CreateonionRequest { impl From<&pb::DeldatastoreRequest> for requests::DeldatastoreRequest { fn from(c: &pb::DeldatastoreRequest) -> Self { Self { - key: c.key.iter().map(|s| s.into()).collect(), + key: c.key.iter().map(|s| s.into()).collect(), // Rule #4 generation: c.generation.clone(), // Rule #1 for type u64? } } @@ -1009,7 +1128,7 @@ impl From<&pb::DeldatastoreRequest> for requests::DeldatastoreRequest { impl From<&pb::DelexpiredinvoiceRequest> for requests::DelexpiredinvoiceRequest { fn from(c: &pb::DelexpiredinvoiceRequest) -> Self { Self { - maxexpirytime: c.maxexpirytime.clone(), // Rule #1 for type u32 + maxexpirytime: c.maxexpirytime.clone(), // Rule #1 for type u64? } } } @@ -1020,6 +1139,7 @@ impl From<&pb::DelinvoiceRequest> for requests::DelinvoiceRequest { Self { label: c.label.clone(), // Rule #1 for type string status: c.status.try_into().unwrap(), + desconly: c.desconly.clone(), // Rule #1 for type boolean? } } } @@ -1028,12 +1148,15 @@ 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|any + msatoshi: c.msatoshi.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 - fallbacks: c.fallbacks.iter().map(|s| s.into()).collect(), + expiry: c.expiry.clone(), // Rule #1 for type u64? + fallbacks: Some(c.fallbacks.iter().map(|s| s.into()).collect()), // Rule #4 preimage: c.preimage.clone().map(|v| hex::encode(v)), // Rule #1 for type hex? + exposeprivatechannels: c.exposeprivatechannels.clone(), // Rule #1 for type boolean? cltv: c.cltv.clone(), // Rule #1 for type u32? + deschashonly: c.deschashonly.clone(), // Rule #1 for type boolean? } } } @@ -1042,7 +1165,7 @@ impl From<&pb::InvoiceRequest> for requests::InvoiceRequest { impl From<&pb::ListdatastoreRequest> for requests::ListdatastoreRequest { fn from(c: &pb::ListdatastoreRequest) -> Self { Self { - key: c.key.iter().map(|s| s.into()).collect(), + key: Some(c.key.iter().map(|s| s.into()).collect()), // Rule #4 } } } @@ -1064,6 +1187,15 @@ impl From<&pb::SendonionRequest> for requests::SendonionRequest { fn from(c: &pb::SendonionRequest) -> Self { Self { onion: hex::encode(&c.onion), // Rule #1 for type hex + payment_hash: c.payment_hash.clone().try_into().unwrap(), // Rule #1 for type hash + label: c.label.clone(), // Rule #1 for type string? + 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? + 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? } } } @@ -1073,7 +1205,7 @@ impl From<&pb::ListsendpaysRequest> for requests::ListsendpaysRequest { fn from(c: &pb::ListsendpaysRequest) -> Self { Self { bolt11: c.bolt11.clone(), // Rule #1 for type string? - payment_hash: c.payment_hash.clone().map(|v| hex::encode(v)), // Rule #1 for type hex? + payment_hash: c.payment_hash.clone().map(|v| v.try_into().unwrap()), // Rule #1 for type hash? status: c.status.map(|v| v.try_into().unwrap()), } } @@ -1094,11 +1226,13 @@ impl From<&pb::PayRequest> for requests::PayRequest { bolt11: c.bolt11.clone(), // Rule #1 for type string msatoshi: c.msatoshi.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 float? - maxfeepercent: c.maxfeepercent.clone(), // Rule #1 for type f32? + riskfactor: c.riskfactor.clone(), // Rule #1 for type number? + maxfeepercent: c.maxfeepercent.clone(), // Rule #1 for type number? retry_for: c.retry_for.map(|v| v as u16), // Rule #1 for type u16? maxdelay: c.maxdelay.map(|v| v as u16), // Rule #1 for type u16? - exemptfee: c.exemptfee.clone(), // Rule #1 for type f32? + exemptfee: c.exemptfee.as_ref().map(|a| a.into()), // Rule #1 for type msat? + localofferid: c.localofferid.clone().map(|v| hex::encode(v)), // Rule #1 for type hex? + exclude: Some(c.exclude.iter().map(|s| s.into()).collect()), // Rule #4 } } } @@ -1107,7 +1241,7 @@ impl From<&pb::PayRequest> for requests::PayRequest { impl From<&pb::ListnodesRequest> for requests::ListnodesRequest { fn from(c: &pb::ListnodesRequest) -> Self { Self { - id: c.id.clone().map(|v| hex::encode(v)), // Rule #1 for type pubkey? + id: c.id.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey? } } } @@ -1116,8 +1250,8 @@ impl From<&pb::ListnodesRequest> for requests::ListnodesRequest { impl From<&pb::WaitanyinvoiceRequest> for requests::WaitanyinvoiceRequest { fn from(c: &pb::WaitanyinvoiceRequest) -> Self { Self { - lastpay_index: c.lastpay_index.clone(), // Rule #1 for type number? - timeout: c.timeout.clone(), // Rule #1 for type number? + lastpay_index: c.lastpay_index.clone(), // Rule #1 for type u64? + timeout: c.timeout.clone(), // Rule #1 for type u64? } } } @@ -1135,9 +1269,10 @@ impl From<&pb::WaitinvoiceRequest> for requests::WaitinvoiceRequest { impl From<&pb::WaitsendpayRequest> for requests::WaitsendpayRequest { fn from(c: &pb::WaitsendpayRequest) -> Self { Self { - payment_hash: hex::encode(&c.payment_hash), // Rule #1 for type hex - partid: c.partid.map(|v| v as u16), // Rule #1 for type u16? + payment_hash: c.payment_hash.clone().try_into().unwrap(), // Rule #1 for type hash timeout: c.timeout.clone(), // Rule #1 for type u32? + partid: c.partid.clone(), // Rule #1 for type u64? + groupid: c.groupid.clone(), // Rule #1 for type u64? } } } @@ -1155,11 +1290,11 @@ impl From<&pb::NewaddrRequest> for requests::NewaddrRequest { impl From<&pb::WithdrawRequest> for requests::WithdrawRequest { fn from(c: &pb::WithdrawRequest) -> Self { Self { - destination: hex::encode(&c.destination), // Rule #1 for type pubkey - satoshi: c.satoshi.as_ref().map(|a| a.into()), // Rule #1 for type msat|all? + destination: c.destination.clone(), // Rule #1 for type string + satoshi: c.satoshi.as_ref().map(|a| a.into()), // Rule #1 for type msat_or_all? feerate: c.feerate.as_ref().map(|a| a.into()), // Rule #1 for type feerate? minconf: c.minconf.map(|v| v as u16), // Rule #1 for type u16? - utxos: c.utxos.iter().map(|s| s.into()).collect(), + utxos: Some(c.utxos.iter().map(|s| s.into()).collect()), // Rule #4 } } } @@ -1168,13 +1303,14 @@ impl From<&pb::WithdrawRequest> for requests::WithdrawRequest { impl From<&pb::KeysendRequest> for requests::KeysendRequest { fn from(c: &pb::KeysendRequest) -> Self { Self { - destination: hex::encode(&c.destination), // 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 label: c.label.clone(), // Rule #1 for type string? - maxfeepercent: c.maxfeepercent.clone(), // Rule #1 for type float? - retry_for: c.retry_for.clone(), // Rule #1 for type number? - maxdelay: c.maxdelay.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? + maxdelay: c.maxdelay.clone(), // Rule #1 for type u32? exemptfee: c.exemptfee.as_ref().map(|a| a.into()), // Rule #1 for type msat? + routehints: c.routehints.clone().map(|rl| rl.into()), // Rule #1 for type RoutehintList? } } } @@ -1185,11 +1321,12 @@ impl From<&pb::FundpsbtRequest> for requests::FundpsbtRequest { Self { satoshi: c.satoshi.as_ref().unwrap().into(), // Rule #1 for type msat feerate: c.feerate.as_ref().unwrap().into(), // Rule #1 for type feerate - startweight: c.startweight.clone(), // Rule #1 for type number - minconf: c.minconf.clone(), // Rule #1 for type number? - reserve: c.reserve.clone(), // Rule #1 for type number? - locktime: c.locktime.clone(), // Rule #1 for type number? + startweight: c.startweight.clone(), // Rule #1 for type u32 + minconf: c.minconf.clone(), // Rule #1 for type u32? + reserve: c.reserve.clone(), // Rule #1 for type u32? + locktime: c.locktime.clone(), // Rule #1 for type u32? min_witness_weight: c.min_witness_weight.clone(), // Rule #1 for type u32? + excess_as_change: c.excess_as_change.clone(), // Rule #1 for type boolean? } } } @@ -1199,6 +1336,7 @@ impl From<&pb::SendpsbtRequest> for requests::SendpsbtRequest { fn from(c: &pb::SendpsbtRequest) -> Self { Self { psbt: c.psbt.clone(), // Rule #1 for type string + reserve: c.reserve.clone(), // Rule #1 for type boolean? } } } @@ -1208,6 +1346,7 @@ impl From<&pb::SignpsbtRequest> for requests::SignpsbtRequest { fn from(c: &pb::SignpsbtRequest) -> Self { Self { psbt: c.psbt.clone(), // Rule #1 for type string + signonly: Some(c.signonly.iter().map(|s| s.clone()).collect()), // Rule #4 } } } @@ -1218,11 +1357,13 @@ impl From<&pb::UtxopsbtRequest> for requests::UtxopsbtRequest { Self { satoshi: c.satoshi.as_ref().unwrap().into(), // Rule #1 for type msat feerate: c.feerate.as_ref().unwrap().into(), // Rule #1 for type feerate - startweight: c.startweight.clone(), // Rule #1 for type number - utxos: c.utxos.iter().map(|s| s.into()).collect(), - reserve: c.reserve.clone(), // Rule #1 for type number? - locktime: c.locktime.clone(), // Rule #1 for type number? + startweight: c.startweight.clone(), // Rule #1 for type u32 + utxos: c.utxos.iter().map(|s| s.into()).collect(), // Rule #4 + reserve: c.reserve.clone(), // Rule #1 for type u32? + reservedok: c.reservedok.clone(), // Rule #1 for type boolean? + locktime: c.locktime.clone(), // Rule #1 for type u32? min_witness_weight: c.min_witness_weight.clone(), // Rule #1 for type u32? + excess_as_change: c.excess_as_change.clone(), // Rule #1 for type boolean? } } } @@ -1231,7 +1372,7 @@ impl From<&pb::UtxopsbtRequest> for requests::UtxopsbtRequest { impl From<&pb::TxdiscardRequest> for requests::TxdiscardRequest { fn from(c: &pb::TxdiscardRequest) -> Self { Self { - txid: hex::encode(&c.txid), // Rule #1 for type hex + txid: hex::encode(&c.txid), // Rule #1 for type txid } } } @@ -1240,10 +1381,10 @@ impl From<&pb::TxdiscardRequest> for requests::TxdiscardRequest { impl From<&pb::TxprepareRequest> for requests::TxprepareRequest { fn from(c: &pb::TxprepareRequest) -> Self { Self { - outptus: c.outptus.iter().map(|s| s.into()).collect(), + outputs: c.outputs.iter().map(|s| s.into()).collect(), // Rule #4 feerate: c.feerate.as_ref().map(|a| a.into()), // Rule #1 for type feerate? minconf: c.minconf.clone(), // Rule #1 for type u32? - utxos: c.utxos.iter().map(|s| s.into()).collect(), + utxos: Some(c.utxos.iter().map(|s| s.into()).collect()), // Rule #4 } } } @@ -1252,7 +1393,84 @@ impl From<&pb::TxprepareRequest> for requests::TxprepareRequest { impl From<&pb::TxsendRequest> for requests::TxsendRequest { fn from(c: &pb::TxsendRequest) -> Self { Self { - txid: hex::encode(&c.txid), // Rule #1 for type hex + txid: hex::encode(&c.txid), // Rule #1 for type txid + } + } +} + +#[allow(unused_variables)] +impl From<&pb::DisconnectRequest> for requests::DisconnectRequest { + fn from(c: &pb::DisconnectRequest) -> Self { + Self { + id: cln_rpc::primitives::Pubkey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey + force: c.force.clone(), // Rule #1 for type boolean? + } + } +} + +#[allow(unused_variables)] +impl From<&pb::FeeratesRequest> for requests::FeeratesRequest { + fn from(c: &pb::FeeratesRequest) -> Self { + Self { + style: c.style.try_into().unwrap(), + } + } +} + +#[allow(unused_variables)] +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 + 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? + fuzzpercent: c.fuzzpercent.clone(), // Rule #1 for type u32? + exclude: Some(c.exclude.iter().map(|s| s.into()).collect()), // Rule #4 + maxhops: c.maxhops.clone(), // Rule #1 for type u32? + } + } +} + +#[allow(unused_variables)] +impl From<&pb::ListforwardsRequest> for requests::ListforwardsRequest { + fn from(c: &pb::ListforwardsRequest) -> Self { + Self { + status: c.status.map(|v| v.try_into().unwrap()), + in_channel: c.in_channel.as_ref().map(|v| cln_rpc::primitives::ShortChannelId::from_str(&v).unwrap()), // Rule #1 for type short_channel_id? + out_channel: c.out_channel.as_ref().map(|v| cln_rpc::primitives::ShortChannelId::from_str(&v).unwrap()), // Rule #1 for type short_channel_id? + } + } +} + +#[allow(unused_variables)] +impl From<&pb::ListpaysRequest> for requests::ListpaysRequest { + fn from(c: &pb::ListpaysRequest) -> Self { + Self { + bolt11: c.bolt11.clone(), // Rule #1 for type string? + payment_hash: c.payment_hash.clone().map(|v| v.try_into().unwrap()), // Rule #1 for type hash? + status: c.status.map(|v| v.try_into().unwrap()), + } + } +} + +#[allow(unused_variables)] +impl From<&pb::PingRequest> for requests::PingRequest { + fn from(c: &pb::PingRequest) -> Self { + Self { + id: cln_rpc::primitives::Pubkey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey + len: c.len.clone(), // Rule #1 for type number? + pongbytes: c.pongbytes.clone(), // Rule #1 for type number? + } + } +} + +#[allow(unused_variables)] +impl From<&pb::SignmessageRequest> for requests::SignmessageRequest { + fn from(c: &pb::SignmessageRequest) -> Self { + Self { + message: c.message.clone(), // Rule #1 for type string } } } diff --git a/cln-grpc/src/server.rs b/cln-grpc/src/server.rs index 5d695b305df2..5ebdfeaefddd 100644 --- a/cln-grpc/src/server.rs +++ b/cln-grpc/src/server.rs @@ -1210,4 +1210,228 @@ async fn tx_send( } +async fn disconnect( + &self, + request: tonic::Request, +) -> Result, tonic::Status> { + let req = request.into_inner(); + let req: requests::DisconnectRequest = (&req).into(); + debug!("Client asked for disconnect"); + trace!("disconnect request: {:?}", req); + let mut rpc = ClnRpc::new(&self.rpc_path) + .await + .map_err(|e| Status::new(Code::Internal, e.to_string()))?; + let result = rpc.call(Request::Disconnect(req)) + .await + .map_err(|e| Status::new( + Code::Unknown, + format!("Error calling method Disconnect: {:?}", e)))?; + match result { + Response::Disconnect(r) => { + trace!("disconnect response: {:?}", r); + Ok(tonic::Response::new((&r).into())) + }, + r => Err(Status::new( + Code::Internal, + format!( + "Unexpected result {:?} to method call Disconnect", + r + ) + )), + } + +} + +async fn feerates( + &self, + request: tonic::Request, +) -> Result, tonic::Status> { + let req = request.into_inner(); + let req: requests::FeeratesRequest = (&req).into(); + debug!("Client asked for feerates"); + trace!("feerates request: {:?}", req); + let mut rpc = ClnRpc::new(&self.rpc_path) + .await + .map_err(|e| Status::new(Code::Internal, e.to_string()))?; + let result = rpc.call(Request::Feerates(req)) + .await + .map_err(|e| Status::new( + Code::Unknown, + format!("Error calling method Feerates: {:?}", e)))?; + match result { + Response::Feerates(r) => { + trace!("feerates response: {:?}", r); + Ok(tonic::Response::new((&r).into())) + }, + r => Err(Status::new( + Code::Internal, + format!( + "Unexpected result {:?} to method call Feerates", + r + ) + )), + } + +} + +async fn get_route( + &self, + request: tonic::Request, +) -> Result, tonic::Status> { + let req = request.into_inner(); + let req: requests::GetrouteRequest = (&req).into(); + debug!("Client asked for get_route"); + trace!("get_route request: {:?}", req); + let mut rpc = ClnRpc::new(&self.rpc_path) + .await + .map_err(|e| Status::new(Code::Internal, e.to_string()))?; + let result = rpc.call(Request::GetRoute(req)) + .await + .map_err(|e| Status::new( + Code::Unknown, + format!("Error calling method GetRoute: {:?}", e)))?; + match result { + Response::GetRoute(r) => { + trace!("get_route response: {:?}", r); + Ok(tonic::Response::new((&r).into())) + }, + r => Err(Status::new( + Code::Internal, + format!( + "Unexpected result {:?} to method call GetRoute", + r + ) + )), + } + +} + +async fn list_forwards( + &self, + request: tonic::Request, +) -> Result, tonic::Status> { + let req = request.into_inner(); + let req: requests::ListforwardsRequest = (&req).into(); + debug!("Client asked for list_forwards"); + trace!("list_forwards request: {:?}", req); + let mut rpc = ClnRpc::new(&self.rpc_path) + .await + .map_err(|e| Status::new(Code::Internal, e.to_string()))?; + let result = rpc.call(Request::ListForwards(req)) + .await + .map_err(|e| Status::new( + Code::Unknown, + format!("Error calling method ListForwards: {:?}", e)))?; + match result { + Response::ListForwards(r) => { + trace!("list_forwards response: {:?}", r); + Ok(tonic::Response::new((&r).into())) + }, + r => Err(Status::new( + Code::Internal, + format!( + "Unexpected result {:?} to method call ListForwards", + r + ) + )), + } + +} + +async fn list_pays( + &self, + request: tonic::Request, +) -> Result, tonic::Status> { + let req = request.into_inner(); + let req: requests::ListpaysRequest = (&req).into(); + debug!("Client asked for list_pays"); + trace!("list_pays request: {:?}", req); + let mut rpc = ClnRpc::new(&self.rpc_path) + .await + .map_err(|e| Status::new(Code::Internal, e.to_string()))?; + let result = rpc.call(Request::ListPays(req)) + .await + .map_err(|e| Status::new( + Code::Unknown, + format!("Error calling method ListPays: {:?}", e)))?; + match result { + Response::ListPays(r) => { + trace!("list_pays response: {:?}", r); + Ok(tonic::Response::new((&r).into())) + }, + r => Err(Status::new( + Code::Internal, + format!( + "Unexpected result {:?} to method call ListPays", + r + ) + )), + } + +} + +async fn ping( + &self, + request: tonic::Request, +) -> Result, tonic::Status> { + let req = request.into_inner(); + let req: requests::PingRequest = (&req).into(); + debug!("Client asked for ping"); + trace!("ping request: {:?}", req); + let mut rpc = ClnRpc::new(&self.rpc_path) + .await + .map_err(|e| Status::new(Code::Internal, e.to_string()))?; + let result = rpc.call(Request::Ping(req)) + .await + .map_err(|e| Status::new( + Code::Unknown, + format!("Error calling method Ping: {:?}", e)))?; + match result { + Response::Ping(r) => { + trace!("ping response: {:?}", r); + Ok(tonic::Response::new((&r).into())) + }, + r => Err(Status::new( + Code::Internal, + format!( + "Unexpected result {:?} to method call Ping", + r + ) + )), + } + +} + +async fn sign_message( + &self, + request: tonic::Request, +) -> Result, tonic::Status> { + let req = request.into_inner(); + let req: requests::SignmessageRequest = (&req).into(); + debug!("Client asked for sign_message"); + trace!("sign_message request: {:?}", req); + let mut rpc = ClnRpc::new(&self.rpc_path) + .await + .map_err(|e| Status::new(Code::Internal, e.to_string()))?; + let result = rpc.call(Request::SignMessage(req)) + .await + .map_err(|e| Status::new( + Code::Unknown, + format!("Error calling method SignMessage: {:?}", e)))?; + match result { + Response::SignMessage(r) => { + trace!("sign_message response: {:?}", r); + Ok(tonic::Response::new((&r).into())) + }, + r => Err(Status::new( + Code::Internal, + format!( + "Unexpected result {:?} to method call SignMessage", + r + ) + )), + } + +} + } diff --git a/cln-rpc/src/model.rs b/cln-rpc/src/model.rs index be76d10ceba0..5a4aaa4aa9e0 100644 --- a/cln-rpc/src/model.rs +++ b/cln-rpc/src/model.rs @@ -53,6 +53,13 @@ pub enum Request { TxDiscard(requests::TxdiscardRequest), TxPrepare(requests::TxprepareRequest), TxSend(requests::TxsendRequest), + Disconnect(requests::DisconnectRequest), + Feerates(requests::FeeratesRequest), + GetRoute(requests::GetrouteRequest), + ListForwards(requests::ListforwardsRequest), + ListPays(requests::ListpaysRequest), + Ping(requests::PingRequest), + SignMessage(requests::SignmessageRequest), } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -96,6 +103,13 @@ pub enum Response { TxDiscard(responses::TxdiscardResponse), TxPrepare(responses::TxprepareResponse), TxSend(responses::TxsendResponse), + Disconnect(responses::DisconnectResponse), + Feerates(responses::FeeratesResponse), + GetRoute(responses::GetrouteResponse), + ListForwards(responses::ListforwardsResponse), + ListPays(responses::ListpaysResponse), + Ping(responses::PingResponse), + SignMessage(responses::SignmessageResponse), } pub mod requests { @@ -111,7 +125,7 @@ pub mod requests { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ListpeersRequest { #[serde(alias = "id", skip_serializing_if = "Option::is_none")] - pub id: Option, + pub id: Option, #[serde(alias = "level", skip_serializing_if = "Option::is_none")] pub level: Option, } @@ -127,11 +141,11 @@ pub mod requests { #[serde(alias = "msatoshi")] pub msatoshi: Amount, #[serde(alias = "id")] - pub id: String, + pub id: Pubkey, #[serde(alias = "delay")] pub delay: u16, #[serde(alias = "channel")] - pub channel: String, + pub channel: ShortChannelId, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -139,7 +153,7 @@ pub mod requests { #[serde(alias = "route")] pub route: Vec, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, #[serde(alias = "label", skip_serializing_if = "Option::is_none")] pub label: Option, #[serde(alias = "msatoshi", skip_serializing_if = "Option::is_none")] @@ -147,19 +161,23 @@ pub mod requests { #[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")] pub bolt11: Option, #[serde(alias = "payment_secret", skip_serializing_if = "Option::is_none")] - pub payment_secret: Option, + pub payment_secret: Option, #[serde(alias = "partid", skip_serializing_if = "Option::is_none")] pub partid: Option, + #[serde(alias = "localofferid", skip_serializing_if = "Option::is_none")] + pub localofferid: Option, + #[serde(alias = "groupid", skip_serializing_if = "Option::is_none")] + pub groupid: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ListchannelsRequest { #[serde(alias = "short_channel_id", skip_serializing_if = "Option::is_none")] - pub short_channel_id: Option, + pub short_channel_id: Option, #[serde(alias = "source", skip_serializing_if = "Option::is_none")] - pub source: Option, + pub source: Option, #[serde(alias = "destination", skip_serializing_if = "Option::is_none")] - pub destination: Option, + pub destination: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -183,7 +201,7 @@ pub mod requests { #[serde(alias = "zbase")] pub zbase: String, #[serde(alias = "pubkey", skip_serializing_if = "Option::is_none")] - pub pubkey: Option, + pub pubkey: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -200,6 +218,8 @@ pub mod requests { pub wrong_funding: Option, #[serde(alias = "force_lease_closed", skip_serializing_if = "Option::is_none")] pub force_lease_closed: Option, + #[serde(alias = "feerange", skip_serializing_if = "Option::is_none")] + pub feerange: Option>, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -223,12 +243,16 @@ pub mod requests { } #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum DatastoreMode { + #[serde(rename = "must-create")] MUST_CREATE, + #[serde(rename = "must-replace")] MUST_REPLACE, + #[serde(rename = "create-or-replace")] CREATE_OR_REPLACE, + #[serde(rename = "must-append")] MUST_APPEND, + #[serde(rename = "create-or-append")] CREATE_OR_APPEND, } @@ -249,6 +273,8 @@ pub mod requests { pub struct DatastoreRequest { #[serde(alias = "key")] pub key: Vec, + #[serde(alias = "string", skip_serializing_if = "Option::is_none")] + pub string: Option, #[serde(alias = "hex", skip_serializing_if = "Option::is_none")] pub hex: Option, pub mode: Option, @@ -259,7 +285,7 @@ pub mod requests { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct CreateonionHops { #[serde(alias = "pubkey")] - pub pubkey: String, + pub pubkey: Pubkey, #[serde(alias = "payload")] pub payload: String, } @@ -271,7 +297,7 @@ pub mod requests { #[serde(alias = "assocdata")] pub assocdata: String, #[serde(alias = "session_key", skip_serializing_if = "Option::is_none")] - pub session_key: Option, + pub session_key: Option, #[serde(alias = "onion_size", skip_serializing_if = "Option::is_none")] pub onion_size: Option, } @@ -286,15 +312,17 @@ pub mod requests { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct DelexpiredinvoiceRequest { - #[serde(alias = "maxexpirytime")] - pub maxexpirytime: u32, + #[serde(alias = "maxexpirytime", skip_serializing_if = "Option::is_none")] + pub maxexpirytime: Option, } #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum DelinvoiceStatus { + #[serde(rename = "paid")] PAID, + #[serde(rename = "expired")] EXPIRED, + #[serde(rename = "unpaid")] UNPAID, } @@ -316,6 +344,8 @@ pub mod requests { // Path `DelInvoice.status` #[serde(rename = "status")] pub status: DelinvoiceStatus, + #[serde(alias = "desconly", skip_serializing_if = "Option::is_none")] + pub desconly: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -326,18 +356,24 @@ pub mod requests { pub description: String, #[serde(alias = "label")] pub label: String, - #[serde(alias = "fallbacks")] - pub fallbacks: Vec, + #[serde(alias = "expiry", skip_serializing_if = "Option::is_none")] + pub expiry: Option, + #[serde(alias = "fallbacks", skip_serializing_if = "Option::is_none")] + pub fallbacks: Option>, #[serde(alias = "preimage", skip_serializing_if = "Option::is_none")] pub preimage: Option, + #[serde(alias = "exposeprivatechannels", skip_serializing_if = "Option::is_none")] + pub exposeprivatechannels: Option, #[serde(alias = "cltv", skip_serializing_if = "Option::is_none")] pub cltv: Option, + #[serde(alias = "deschashonly", skip_serializing_if = "Option::is_none")] + pub deschashonly: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ListdatastoreRequest { - #[serde(alias = "key")] - pub key: Vec, + #[serde(alias = "key", skip_serializing_if = "Option::is_none")] + pub key: Option>, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -355,7 +391,7 @@ pub mod requests { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SendonionFirst_hop { #[serde(alias = "id")] - pub id: String, + pub id: Pubkey, #[serde(alias = "amount_msat")] pub amount_msat: Amount, #[serde(alias = "delay")] @@ -366,13 +402,33 @@ pub mod requests { pub struct SendonionRequest { #[serde(alias = "onion")] pub onion: String, + #[serde(alias = "payment_hash")] + pub payment_hash: Sha256, + #[serde(alias = "label", skip_serializing_if = "Option::is_none")] + pub label: Option, + #[serde(alias = "shared_secrets", skip_serializing_if = "Option::is_none")] + pub shared_secrets: Option>, + #[serde(alias = "partid", skip_serializing_if = "Option::is_none")] + pub partid: Option, + #[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")] + pub bolt11: Option, + #[serde(alias = "msatoshi", skip_serializing_if = "Option::is_none")] + pub msatoshi: Option, + #[serde(alias = "destination", skip_serializing_if = "Option::is_none")] + pub destination: Option, + #[serde(alias = "localofferid", skip_serializing_if = "Option::is_none")] + pub localofferid: Option, + #[serde(alias = "groupid", skip_serializing_if = "Option::is_none")] + pub groupid: Option, } #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum ListsendpaysStatus { + #[serde(rename = "pending")] PENDING, + #[serde(rename = "complete")] COMPLETE, + #[serde(rename = "failed")] FAILED, } @@ -392,7 +448,7 @@ pub mod requests { #[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")] pub bolt11: Option, #[serde(alias = "payment_hash", skip_serializing_if = "Option::is_none")] - pub payment_hash: Option, + pub payment_hash: Option, pub status: Option, } @@ -409,29 +465,33 @@ pub mod requests { #[serde(alias = "label", skip_serializing_if = "Option::is_none")] pub label: Option, #[serde(alias = "riskfactor", skip_serializing_if = "Option::is_none")] - pub riskfactor: Option, + pub riskfactor: Option, #[serde(alias = "maxfeepercent", skip_serializing_if = "Option::is_none")] - pub maxfeepercent: Option, + pub maxfeepercent: Option, #[serde(alias = "retry_for", skip_serializing_if = "Option::is_none")] pub retry_for: Option, #[serde(alias = "maxdelay", skip_serializing_if = "Option::is_none")] pub maxdelay: Option, #[serde(alias = "exemptfee", skip_serializing_if = "Option::is_none")] - pub exemptfee: Option, + pub exemptfee: Option, + #[serde(alias = "localofferid", skip_serializing_if = "Option::is_none")] + pub localofferid: Option, + #[serde(alias = "exclude", skip_serializing_if = "Option::is_none")] + pub exclude: Option>, } #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ListnodesRequest { #[serde(alias = "id", skip_serializing_if = "Option::is_none")] - pub id: Option, + pub id: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] pub struct WaitanyinvoiceRequest { #[serde(alias = "lastpay_index", skip_serializing_if = "Option::is_none")] - pub lastpay_index: Option, + pub lastpay_index: Option, #[serde(alias = "timeout", skip_serializing_if = "Option::is_none")] - pub timeout: Option, + pub timeout: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -443,18 +503,23 @@ pub mod requests { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct WaitsendpayRequest { #[serde(alias = "payment_hash")] - pub payment_hash: String, - #[serde(alias = "partid", skip_serializing_if = "Option::is_none")] - pub partid: Option, + pub payment_hash: Sha256, #[serde(alias = "timeout", skip_serializing_if = "Option::is_none")] pub timeout: Option, + #[serde(alias = "partid", skip_serializing_if = "Option::is_none")] + pub partid: Option, + #[serde(alias = "groupid", skip_serializing_if = "Option::is_none")] + pub groupid: Option, } #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum NewaddrAddresstype { + #[serde(rename = "bech32")] BECH32, + #[serde(rename = "p2sh-segwit")] P2SH_SEGWIT, + #[serde(rename = "all")] + ALL, } impl TryFrom for NewaddrAddresstype { @@ -463,6 +528,7 @@ pub mod requests { match c { 0 => Ok(NewaddrAddresstype::BECH32), 1 => Ok(NewaddrAddresstype::P2SH_SEGWIT), + 2 => Ok(NewaddrAddresstype::ALL), o => Err(anyhow::anyhow!("Unknown variant {} for enum NewaddrAddresstype", o)), } } @@ -482,26 +548,32 @@ pub mod requests { pub feerate: Option, #[serde(alias = "minconf", skip_serializing_if = "Option::is_none")] pub minconf: Option, - #[serde(alias = "utxos")] - pub utxos: Vec, + #[serde(alias = "utxos", skip_serializing_if = "Option::is_none")] + pub utxos: Option>, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct KeysendExtratlvs { } #[derive(Clone, Debug, Deserialize, Serialize)] pub struct KeysendRequest { #[serde(alias = "destination")] - pub destination: String, + pub destination: Pubkey, #[serde(alias = "msatoshi")] pub msatoshi: Amount, #[serde(alias = "label", skip_serializing_if = "Option::is_none")] pub label: Option, #[serde(alias = "maxfeepercent", skip_serializing_if = "Option::is_none")] - pub maxfeepercent: Option, + pub maxfeepercent: Option, #[serde(alias = "retry_for", skip_serializing_if = "Option::is_none")] - pub retry_for: Option, + pub retry_for: Option, #[serde(alias = "maxdelay", skip_serializing_if = "Option::is_none")] - pub maxdelay: Option, + pub maxdelay: Option, #[serde(alias = "exemptfee", skip_serializing_if = "Option::is_none")] pub exemptfee: Option, + #[serde(alias = "routehints", skip_serializing_if = "Option::is_none")] + pub routehints: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -511,27 +583,33 @@ pub mod requests { #[serde(alias = "feerate")] pub feerate: Feerate, #[serde(alias = "startweight")] - pub startweight: i64, + pub startweight: u32, #[serde(alias = "minconf", skip_serializing_if = "Option::is_none")] - pub minconf: Option, + pub minconf: Option, #[serde(alias = "reserve", skip_serializing_if = "Option::is_none")] - pub reserve: Option, + pub reserve: Option, #[serde(alias = "locktime", skip_serializing_if = "Option::is_none")] - pub locktime: Option, + pub locktime: Option, #[serde(alias = "min_witness_weight", skip_serializing_if = "Option::is_none")] pub min_witness_weight: Option, + #[serde(alias = "excess_as_change", skip_serializing_if = "Option::is_none")] + pub excess_as_change: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SendpsbtRequest { #[serde(alias = "psbt")] pub psbt: String, + #[serde(alias = "reserve", skip_serializing_if = "Option::is_none")] + pub reserve: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SignpsbtRequest { #[serde(alias = "psbt")] pub psbt: String, + #[serde(alias = "signonly", skip_serializing_if = "Option::is_none")] + pub signonly: Option>, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -541,15 +619,19 @@ pub mod requests { #[serde(alias = "feerate")] pub feerate: Feerate, #[serde(alias = "startweight")] - pub startweight: i64, + pub startweight: u32, #[serde(alias = "utxos")] - pub utxos: Vec, + pub utxos: Vec, #[serde(alias = "reserve", skip_serializing_if = "Option::is_none")] - pub reserve: Option, + pub reserve: Option, + #[serde(alias = "reservedok", skip_serializing_if = "Option::is_none")] + pub reservedok: Option, #[serde(alias = "locktime", skip_serializing_if = "Option::is_none")] - pub locktime: Option, + pub locktime: Option, #[serde(alias = "min_witness_weight", skip_serializing_if = "Option::is_none")] pub min_witness_weight: Option, + #[serde(alias = "excess_as_change", skip_serializing_if = "Option::is_none")] + pub excess_as_change: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -560,14 +642,14 @@ pub mod requests { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct TxprepareRequest { - #[serde(alias = "outptus")] - pub outptus: Vec, + #[serde(alias = "outputs")] + pub outputs: Vec, #[serde(alias = "feerate", skip_serializing_if = "Option::is_none")] pub feerate: Option, #[serde(alias = "minconf", skip_serializing_if = "Option::is_none")] pub minconf: Option, - #[serde(alias = "utxos")] - pub utxos: Vec, + #[serde(alias = "utxos", skip_serializing_if = "Option::is_none")] + pub utxos: Option>, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -576,6 +658,138 @@ pub mod requests { pub txid: String, } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct DisconnectRequest { + #[serde(alias = "id")] + pub id: Pubkey, + #[serde(alias = "force", skip_serializing_if = "Option::is_none")] + pub force: Option, + } + + #[derive(Copy, Clone, Debug, Deserialize, Serialize)] + pub enum FeeratesStyle { + #[serde(rename = "perkb")] + PERKB, + #[serde(rename = "perkw")] + PERKW, + } + + impl TryFrom for FeeratesStyle { + type Error = anyhow::Error; + fn try_from(c: i32) -> Result { + match c { + 0 => Ok(FeeratesStyle::PERKB), + 1 => Ok(FeeratesStyle::PERKW), + o => Err(anyhow::anyhow!("Unknown variant {} for enum FeeratesStyle", o)), + } + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct FeeratesRequest { + // Path `Feerates.style` + #[serde(rename = "style")] + pub style: FeeratesStyle, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct GetrouteRequest { + #[serde(alias = "id")] + pub id: Pubkey, + #[serde(alias = "msatoshi")] + pub msatoshi: Amount, + #[serde(alias = "riskfactor")] + pub riskfactor: u64, + #[serde(alias = "cltv", skip_serializing_if = "Option::is_none")] + pub cltv: Option, + #[serde(alias = "fromid", skip_serializing_if = "Option::is_none")] + pub fromid: Option, + #[serde(alias = "fuzzpercent", skip_serializing_if = "Option::is_none")] + pub fuzzpercent: Option, + #[serde(alias = "exclude", skip_serializing_if = "Option::is_none")] + pub exclude: Option>, + #[serde(alias = "maxhops", skip_serializing_if = "Option::is_none")] + pub maxhops: Option, + } + + #[derive(Copy, Clone, Debug, Deserialize, Serialize)] + pub enum ListforwardsStatus { + #[serde(rename = "offered")] + OFFERED, + #[serde(rename = "settled")] + SETTLED, + #[serde(rename = "local_failed")] + LOCAL_FAILED, + #[serde(rename = "failed")] + FAILED, + } + + impl TryFrom for ListforwardsStatus { + type Error = anyhow::Error; + fn try_from(c: i32) -> Result { + match c { + 0 => Ok(ListforwardsStatus::OFFERED), + 1 => Ok(ListforwardsStatus::SETTLED), + 2 => Ok(ListforwardsStatus::LOCAL_FAILED), + 3 => Ok(ListforwardsStatus::FAILED), + o => Err(anyhow::anyhow!("Unknown variant {} for enum ListforwardsStatus", o)), + } + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct ListforwardsRequest { + pub status: Option, + #[serde(alias = "in_channel", skip_serializing_if = "Option::is_none")] + pub in_channel: Option, + #[serde(alias = "out_channel", skip_serializing_if = "Option::is_none")] + pub out_channel: Option, + } + + #[derive(Copy, Clone, Debug, Deserialize, Serialize)] + pub enum ListpaysStatus { + #[serde(rename = "pending")] + PENDING, + #[serde(rename = "complete")] + COMPLETE, + #[serde(rename = "failed")] + FAILED, + } + + impl TryFrom for ListpaysStatus { + type Error = anyhow::Error; + fn try_from(c: i32) -> Result { + match c { + 0 => Ok(ListpaysStatus::PENDING), + 1 => Ok(ListpaysStatus::COMPLETE), + 2 => Ok(ListpaysStatus::FAILED), + o => Err(anyhow::anyhow!("Unknown variant {} for enum ListpaysStatus", o)), + } + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct ListpaysRequest { + #[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")] + pub bolt11: Option, + #[serde(alias = "payment_hash", skip_serializing_if = "Option::is_none")] + pub payment_hash: Option, + pub status: Option, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct PingRequest { + #[serde(alias = "id")] + pub id: Pubkey, + #[serde(alias = "len", skip_serializing_if = "Option::is_none")] + pub len: Option, + #[serde(alias = "pongbytes", skip_serializing_if = "Option::is_none")] + pub pongbytes: Option, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct SignmessageRequest { + #[serde(alias = "message")] + pub message: String, + } + } @@ -599,13 +813,18 @@ pub mod responses { /// Type of connection #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum GetinfoAddressType { + #[serde(rename = "dns")] DNS, + #[serde(rename = "ipv4")] IPV4, + #[serde(rename = "ipv6")] IPV6, + #[serde(rename = "torv2")] TORV2, + #[serde(rename = "torv3")] TORV3, + #[serde(rename = "websocket")] WEBSOCKET, } @@ -636,12 +855,16 @@ pub mod responses { /// Type of connection #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum GetinfoBindingType { + #[serde(rename = "local socket")] LOCAL_SOCKET, + #[serde(rename = "ipv4")] IPV4, + #[serde(rename = "ipv6")] IPV6, + #[serde(rename = "torv2")] TORV2, + #[serde(rename = "torv3")] TORV3, } @@ -674,7 +897,7 @@ pub mod responses { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct GetinfoResponse { #[serde(alias = "id")] - pub id: String, + pub id: Pubkey, #[serde(alias = "alias")] pub alias: String, #[serde(alias = "color")] @@ -697,10 +920,10 @@ pub mod responses { pub network: String, #[serde(alias = "fees_collected_msat")] pub fees_collected_msat: Amount, - #[serde(alias = "address")] - pub address: Vec, - #[serde(alias = "binding")] - pub binding: Vec, + #[serde(alias = "address", skip_serializing_if = "Option::is_none")] + pub address: Option>, + #[serde(alias = "binding", skip_serializing_if = "Option::is_none")] + pub binding: Option>, #[serde(alias = "warning_bitcoind_sync", skip_serializing_if = "Option::is_none")] pub warning_bitcoind_sync: Option, #[serde(alias = "warning_lightningd_sync", skip_serializing_if = "Option::is_none")] @@ -708,14 +931,20 @@ pub mod responses { } #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum ListpeersPeersLogType { + #[serde(rename = "SKIPPED")] SKIPPED, + #[serde(rename = "BROKEN")] BROKEN, + #[serde(rename = "UNUSUAL")] UNUSUAL, + #[serde(rename = "INFO")] INFO, + #[serde(rename = "DEBUG")] DEBUG, + #[serde(rename = "IO_IN")] IO_IN, + #[serde(rename = "IO_OUT")] IO_OUT, } @@ -748,25 +977,35 @@ pub mod responses { #[serde(alias = "log", skip_serializing_if = "Option::is_none")] pub log: Option, #[serde(alias = "node_id", skip_serializing_if = "Option::is_none")] - pub node_id: Option, + pub node_id: Option, #[serde(alias = "data", skip_serializing_if = "Option::is_none")] pub data: Option, } /// the channel state, in particular "CHANNELD_NORMAL" means the channel can be used normally #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum ListpeersPeersChannelsState { + #[serde(rename = "OPENINGD")] OPENINGD, + #[serde(rename = "CHANNELD_AWAITING_LOCKIN")] CHANNELD_AWAITING_LOCKIN, + #[serde(rename = "CHANNELD_NORMAL")] CHANNELD_NORMAL, + #[serde(rename = "CHANNELD_SHUTTING_DOWN")] CHANNELD_SHUTTING_DOWN, + #[serde(rename = "CLOSINGD_SIGEXCHANGE")] CLOSINGD_SIGEXCHANGE, + #[serde(rename = "CLOSINGD_COMPLETE")] CLOSINGD_COMPLETE, + #[serde(rename = "AWAITING_UNILATERAL")] AWAITING_UNILATERAL, + #[serde(rename = "FUNDING_SPEND_SEEN")] FUNDING_SPEND_SEEN, + #[serde(rename = "ONCHAIN")] ONCHAIN, + #[serde(rename = "DUALOPEND_OPEN_INIT")] DUALOPEND_OPEN_INIT, + #[serde(rename = "DUALOPEND_AWAITING_LOCKIN")] DUALOPEND_AWAITING_LOCKIN, } @@ -842,9 +1081,10 @@ pub mod responses { /// Whether it came from peer, or is going to peer #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum ListpeersPeersChannelsHtlcsDirection { + #[serde(rename = "in")] IN, + #[serde(rename = "out")] OUT, } @@ -858,40 +1098,6 @@ pub mod responses { } } } - /// Status of the HTLC - #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] - pub enum ListpeersPeersChannelsHtlcsState { - SENT_ADD_HTLC, - SENT_ADD_COMMIT, - RCVD_ADD_REVOCATION, - RCVD_ADD_ACK_COMMIT, - SENT_ADD_ACK_REVOCATION, - RCVD_REMOVE_HTLC, - RCVD_REMOVE_COMMIT, - SENT_REMOVE_REVOCATION, - SENT_REMOVE_ACK_COMMIT, - RCVD_REMOVE_ACK_REVOCATION, - } - - impl TryFrom for ListpeersPeersChannelsHtlcsState { - type Error = anyhow::Error; - fn try_from(c: i32) -> Result { - match c { - 0 => Ok(ListpeersPeersChannelsHtlcsState::SENT_ADD_HTLC), - 1 => Ok(ListpeersPeersChannelsHtlcsState::SENT_ADD_COMMIT), - 2 => Ok(ListpeersPeersChannelsHtlcsState::RCVD_ADD_REVOCATION), - 3 => Ok(ListpeersPeersChannelsHtlcsState::RCVD_ADD_ACK_COMMIT), - 4 => Ok(ListpeersPeersChannelsHtlcsState::SENT_ADD_ACK_REVOCATION), - 5 => Ok(ListpeersPeersChannelsHtlcsState::RCVD_REMOVE_HTLC), - 6 => Ok(ListpeersPeersChannelsHtlcsState::RCVD_REMOVE_COMMIT), - 7 => Ok(ListpeersPeersChannelsHtlcsState::SENT_REMOVE_REVOCATION), - 8 => Ok(ListpeersPeersChannelsHtlcsState::SENT_REMOVE_ACK_COMMIT), - 9 => Ok(ListpeersPeersChannelsHtlcsState::RCVD_REMOVE_ACK_REVOCATION), - o => Err(anyhow::anyhow!("Unknown variant {} for enum ListpeersPeersChannelsHtlcsState", o)), - } - } - } #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ListpeersPeersChannelsHtlcs { // Path `ListPeers.peers[].channels[].htlcs[].direction` @@ -904,14 +1110,11 @@ pub mod responses { #[serde(alias = "expiry")] pub expiry: u32, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, #[serde(alias = "local_trimmed", skip_serializing_if = "Option::is_none")] pub local_trimmed: Option, #[serde(alias = "status", skip_serializing_if = "Option::is_none")] pub status: Option, - // Path `ListPeers.peers[].channels[].htlcs[].state` - #[serde(rename = "state")] - pub state: ListpeersPeersChannelsHtlcsState, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -924,9 +1127,9 @@ pub mod responses { #[serde(alias = "owner", skip_serializing_if = "Option::is_none")] pub owner: Option, #[serde(alias = "short_channel_id", skip_serializing_if = "Option::is_none")] - pub short_channel_id: Option, + pub short_channel_id: Option, #[serde(alias = "channel_id", skip_serializing_if = "Option::is_none")] - pub channel_id: Option, + pub channel_id: Option, #[serde(alias = "funding_txid", skip_serializing_if = "Option::is_none")] pub funding_txid: Option, #[serde(alias = "funding_outnum", skip_serializing_if = "Option::is_none")] @@ -939,8 +1142,8 @@ pub mod responses { pub next_feerate: Option, #[serde(alias = "next_fee_step", skip_serializing_if = "Option::is_none")] pub next_fee_step: Option, - #[serde(alias = "inflight")] - pub inflight: Vec, + #[serde(alias = "inflight", skip_serializing_if = "Option::is_none")] + pub inflight: Option>, #[serde(alias = "close_to", skip_serializing_if = "Option::is_none")] pub close_to: Option, #[serde(alias = "private", skip_serializing_if = "Option::is_none")] @@ -948,7 +1151,6 @@ pub mod responses { // Path `ListPeers.peers[].channels[].opener` #[serde(rename = "opener")] pub opener: ChannelSide, - pub closer: Option, #[serde(alias = "features")] pub features: Vec, #[serde(alias = "to_us_msat", skip_serializing_if = "Option::is_none")] @@ -977,16 +1179,20 @@ pub mod responses { pub receivable_msat: Option, #[serde(alias = "minimum_htlc_in_msat", skip_serializing_if = "Option::is_none")] pub minimum_htlc_in_msat: Option, + #[serde(alias = "minimum_htlc_out_msat", skip_serializing_if = "Option::is_none")] + pub minimum_htlc_out_msat: Option, + #[serde(alias = "maximum_htlc_out_msat", skip_serializing_if = "Option::is_none")] + pub maximum_htlc_out_msat: Option, #[serde(alias = "their_to_self_delay", skip_serializing_if = "Option::is_none")] pub their_to_self_delay: Option, #[serde(alias = "our_to_self_delay", skip_serializing_if = "Option::is_none")] pub our_to_self_delay: Option, #[serde(alias = "max_accepted_htlcs", skip_serializing_if = "Option::is_none")] pub max_accepted_htlcs: Option, - #[serde(alias = "state_changes")] - pub state_changes: Vec, - #[serde(alias = "status")] - pub status: Vec, + #[serde(alias = "state_changes", skip_serializing_if = "Option::is_none")] + pub state_changes: Option>, + #[serde(alias = "status", skip_serializing_if = "Option::is_none")] + pub status: Option>, #[serde(alias = "in_payments_offered", skip_serializing_if = "Option::is_none")] pub in_payments_offered: Option, #[serde(alias = "in_offered_msat", skip_serializing_if = "Option::is_none")] @@ -1003,8 +1209,8 @@ pub mod responses { pub out_payments_fulfilled: Option, #[serde(alias = "out_fulfilled_msat", skip_serializing_if = "Option::is_none")] pub out_fulfilled_msat: Option, - #[serde(alias = "htlcs")] - pub htlcs: Vec, + #[serde(alias = "htlcs", skip_serializing_if = "Option::is_none")] + pub htlcs: Option>, #[serde(alias = "close_to_addr", skip_serializing_if = "Option::is_none")] pub close_to_addr: Option, } @@ -1012,15 +1218,15 @@ pub mod responses { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ListpeersPeers { #[serde(alias = "id")] - pub id: String, + pub id: Pubkey, #[serde(alias = "connected")] pub connected: bool, - #[serde(alias = "log")] - pub log: Vec, + #[serde(alias = "log", skip_serializing_if = "Option::is_none")] + pub log: Option>, #[serde(alias = "channels")] pub channels: Vec, - #[serde(alias = "netaddr")] - pub netaddr: Vec, + #[serde(alias = "netaddr", skip_serializing_if = "Option::is_none")] + pub netaddr: Option>, #[serde(alias = "features", skip_serializing_if = "Option::is_none")] pub features: Option, } @@ -1032,10 +1238,12 @@ pub mod responses { } #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum ListfundsOutputsStatus { + #[serde(rename = "unconfirmed")] UNCONFIRMED, + #[serde(rename = "confirmed")] CONFIRMED, + #[serde(rename = "spent")] SPENT, } @@ -1074,7 +1282,7 @@ pub mod responses { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ListfundsChannels { #[serde(alias = "peer_id")] - pub peer_id: String, + pub peer_id: Pubkey, #[serde(alias = "our_amount_msat")] pub our_amount_msat: Amount, #[serde(alias = "amount_msat")] @@ -1089,7 +1297,7 @@ pub mod responses { #[serde(rename = "state")] pub state: ChannelState, #[serde(alias = "short_channel_id", skip_serializing_if = "Option::is_none")] - pub short_channel_id: Option, + pub short_channel_id: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -1102,9 +1310,10 @@ pub mod responses { /// status of the payment (could be complete if already sent previously) #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum SendpayStatus { + #[serde(rename = "pending")] PENDING, + #[serde(rename = "complete")] COMPLETE, } @@ -1125,14 +1334,14 @@ pub mod responses { #[serde(alias = "groupid", skip_serializing_if = "Option::is_none")] pub groupid: Option, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, // Path `SendPay.status` #[serde(rename = "status")] pub status: SendpayStatus, #[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")] pub amount_msat: Option, #[serde(alias = "destination", skip_serializing_if = "Option::is_none")] - pub destination: Option, + pub destination: Option, #[serde(alias = "created_at")] pub created_at: u64, #[serde(alias = "amount_sent_msat")] @@ -1146,7 +1355,7 @@ pub mod responses { #[serde(alias = "bolt12", skip_serializing_if = "Option::is_none")] pub bolt12: Option, #[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")] - pub payment_preimage: Option, + pub payment_preimage: Option, #[serde(alias = "message", skip_serializing_if = "Option::is_none")] pub message: Option, } @@ -1154,11 +1363,11 @@ pub mod responses { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ListchannelsChannels { #[serde(alias = "source")] - pub source: String, + pub source: Pubkey, #[serde(alias = "destination")] - pub destination: String, + pub destination: Pubkey, #[serde(alias = "short_channel_id")] - pub short_channel_id: String, + pub short_channel_id: ShortChannelId, #[serde(alias = "public")] pub public: bool, #[serde(alias = "amount_msat")] @@ -1210,15 +1419,17 @@ pub mod responses { #[serde(alias = "verified")] pub verified: bool, #[serde(alias = "pubkey", skip_serializing_if = "Option::is_none")] - pub pubkey: Option, + pub pubkey: Option, } /// Whether we successfully negotiated a mutual close, closed without them, or discarded not-yet-opened channel #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum CloseType { + #[serde(rename = "mutual")] MUTUAL, + #[serde(rename = "unilateral")] UNILATERAL, + #[serde(rename = "unopened")] UNOPENED, } @@ -1246,9 +1457,10 @@ pub mod responses { /// Whether they initiated connection or we did #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum ConnectDirection { + #[serde(rename = "in")] IN, + #[serde(rename = "out")] OUT, } @@ -1264,12 +1476,16 @@ pub mod responses { } /// Type of connection (*torv2*/*torv3* only if **direction** is *out*) #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum ConnectAddressType { + #[serde(rename = "local socket")] LOCAL_SOCKET, + #[serde(rename = "ipv4")] IPV4, + #[serde(rename = "ipv6")] IPV6, + #[serde(rename = "torv2")] TORV2, + #[serde(rename = "torv3")] TORV3, } @@ -1302,7 +1518,7 @@ pub mod responses { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ConnectResponse { #[serde(alias = "id")] - pub id: String, + pub id: Pubkey, #[serde(alias = "features")] pub features: String, // Path `Connect.direction` @@ -1312,10 +1528,12 @@ pub mod responses { /// Whether it has been paid, or can no longer be paid #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum CreateinvoiceStatus { + #[serde(rename = "paid")] PAID, + #[serde(rename = "expired")] EXPIRED, + #[serde(rename = "unpaid")] UNPAID, } @@ -1339,7 +1557,7 @@ pub mod responses { #[serde(alias = "bolt12", skip_serializing_if = "Option::is_none")] pub bolt12: Option, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, #[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")] pub amount_msat: Option, // Path `CreateInvoice.status` @@ -1356,7 +1574,7 @@ pub mod responses { #[serde(alias = "paid_at", skip_serializing_if = "Option::is_none")] pub paid_at: Option, #[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")] - pub payment_preimage: Option, + pub payment_preimage: Option, #[serde(alias = "local_offer_id", skip_serializing_if = "Option::is_none")] pub local_offer_id: Option, #[serde(alias = "payer_note", skip_serializing_if = "Option::is_none")] @@ -1380,7 +1598,7 @@ pub mod responses { #[serde(alias = "onion")] pub onion: String, #[serde(alias = "shared_secrets")] - pub shared_secrets: Vec, + pub shared_secrets: Vec, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -1401,10 +1619,12 @@ pub mod responses { /// State of invoice #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum DelinvoiceStatus { + #[serde(rename = "paid")] PAID, + #[serde(rename = "expired")] EXPIRED, + #[serde(rename = "unpaid")] UNPAID, } @@ -1432,7 +1652,7 @@ pub mod responses { #[serde(alias = "description", skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, // Path `DelInvoice.status` #[serde(rename = "status")] pub status: DelinvoiceStatus, @@ -1449,9 +1669,9 @@ pub mod responses { #[serde(alias = "bolt11")] pub bolt11: String, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, #[serde(alias = "payment_secret")] - pub payment_secret: String, + pub payment_secret: Secret, #[serde(alias = "expires_at")] pub expires_at: u64, #[serde(alias = "warning_capacity", skip_serializing_if = "Option::is_none")] @@ -1486,10 +1706,12 @@ pub mod responses { /// Whether it's paid, unpaid or unpayable #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum ListinvoicesInvoicesStatus { + #[serde(rename = "unpaid")] UNPAID, + #[serde(rename = "paid")] PAID, + #[serde(rename = "expired")] EXPIRED, } @@ -1508,10 +1730,10 @@ pub mod responses { pub struct ListinvoicesInvoices { #[serde(alias = "label")] pub label: String, - #[serde(alias = "description")] - pub description: String, + #[serde(alias = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, // Path `ListInvoices.invoices[].status` #[serde(rename = "status")] pub status: ListinvoicesInvoicesStatus, @@ -1534,7 +1756,7 @@ pub mod responses { #[serde(alias = "paid_at", skip_serializing_if = "Option::is_none")] pub paid_at: Option, #[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")] - pub payment_preimage: Option, + pub payment_preimage: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -1545,9 +1767,10 @@ pub mod responses { /// status of the payment (could be complete if already sent previously) #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum SendonionStatus { + #[serde(rename = "pending")] PENDING, + #[serde(rename = "complete")] COMPLETE, } @@ -1566,14 +1789,14 @@ pub mod responses { #[serde(alias = "id")] pub id: u64, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, // Path `SendOnion.status` #[serde(rename = "status")] pub status: SendonionStatus, #[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")] pub amount_msat: Option, #[serde(alias = "destination", skip_serializing_if = "Option::is_none")] - pub destination: Option, + pub destination: Option, #[serde(alias = "created_at")] pub created_at: u64, #[serde(alias = "amount_sent_msat")] @@ -1584,18 +1807,22 @@ pub mod responses { pub bolt11: Option, #[serde(alias = "bolt12", skip_serializing_if = "Option::is_none")] pub bolt12: Option, + #[serde(alias = "partid", skip_serializing_if = "Option::is_none")] + pub partid: Option, #[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")] - pub payment_preimage: Option, + pub payment_preimage: Option, #[serde(alias = "message", skip_serializing_if = "Option::is_none")] pub message: Option, } /// status of the payment #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum ListsendpaysPaymentsStatus { + #[serde(rename = "pending")] PENDING, + #[serde(rename = "failed")] FAILED, + #[serde(rename = "complete")] COMPLETE, } @@ -1617,14 +1844,14 @@ pub mod responses { #[serde(alias = "groupid", skip_serializing_if = "Option::is_none")] pub groupid: Option, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, // Path `ListSendPays.payments[].status` #[serde(rename = "status")] pub status: ListsendpaysPaymentsStatus, #[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")] pub amount_msat: Option, #[serde(alias = "destination", skip_serializing_if = "Option::is_none")] - pub destination: Option, + pub destination: Option, #[serde(alias = "created_at")] pub created_at: u64, #[serde(alias = "amount_sent_msat")] @@ -1636,7 +1863,7 @@ pub mod responses { #[serde(alias = "bolt12", skip_serializing_if = "Option::is_none")] pub bolt12: Option, #[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")] - pub payment_preimage: Option, + pub payment_preimage: Option, #[serde(alias = "erroronion", skip_serializing_if = "Option::is_none")] pub erroronion: Option, } @@ -1649,18 +1876,28 @@ pub mod responses { /// the purpose of this input (*EXPERIMENTAL_FEATURES* only) #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum ListtransactionsTransactionsInputsType { + #[serde(rename = "theirs")] THEIRS, + #[serde(rename = "deposit")] DEPOSIT, + #[serde(rename = "withdraw")] WITHDRAW, + #[serde(rename = "channel_funding")] CHANNEL_FUNDING, + #[serde(rename = "channel_mutual_close")] CHANNEL_MUTUAL_CLOSE, + #[serde(rename = "channel_unilateral_close")] CHANNEL_UNILATERAL_CLOSE, + #[serde(rename = "channel_sweep")] CHANNEL_SWEEP, + #[serde(rename = "channel_htlc_success")] CHANNEL_HTLC_SUCCESS, + #[serde(rename = "channel_htlc_timeout")] CHANNEL_HTLC_TIMEOUT, + #[serde(rename = "channel_penalty")] CHANNEL_PENALTY, + #[serde(rename = "channel_unilateral_cheat")] CHANNEL_UNILATERAL_CHEAT, } @@ -1693,23 +1930,33 @@ pub mod responses { pub sequence: u32, pub item_type: Option, #[serde(alias = "channel", skip_serializing_if = "Option::is_none")] - pub channel: Option, + pub channel: Option, } /// the purpose of this output (*EXPERIMENTAL_FEATURES* only) #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum ListtransactionsTransactionsOutputsType { + #[serde(rename = "theirs")] THEIRS, + #[serde(rename = "deposit")] DEPOSIT, + #[serde(rename = "withdraw")] WITHDRAW, + #[serde(rename = "channel_funding")] CHANNEL_FUNDING, + #[serde(rename = "channel_mutual_close")] CHANNEL_MUTUAL_CLOSE, + #[serde(rename = "channel_unilateral_close")] CHANNEL_UNILATERAL_CLOSE, + #[serde(rename = "channel_sweep")] CHANNEL_SWEEP, + #[serde(rename = "channel_htlc_success")] CHANNEL_HTLC_SUCCESS, + #[serde(rename = "channel_htlc_timeout")] CHANNEL_HTLC_TIMEOUT, + #[serde(rename = "channel_penalty")] CHANNEL_PENALTY, + #[serde(rename = "channel_unilateral_cheat")] CHANNEL_UNILATERAL_CHEAT, } @@ -1742,7 +1989,7 @@ pub mod responses { pub script_pub_key: String, pub item_type: Option, #[serde(alias = "channel", skip_serializing_if = "Option::is_none")] - pub channel: Option, + pub channel: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -1756,7 +2003,7 @@ pub mod responses { #[serde(alias = "txindex")] pub txindex: u32, #[serde(alias = "channel", skip_serializing_if = "Option::is_none")] - pub channel: Option, + pub channel: Option, #[serde(alias = "locktime")] pub locktime: u32, #[serde(alias = "version")] @@ -1775,10 +2022,12 @@ pub mod responses { /// status of payment #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum PayStatus { + #[serde(rename = "complete")] COMPLETE, + #[serde(rename = "pending")] PENDING, + #[serde(rename = "failed")] FAILED, } @@ -1796,13 +2045,13 @@ pub mod responses { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct PayResponse { #[serde(alias = "payment_preimage")] - pub payment_preimage: String, + pub payment_preimage: Secret, #[serde(alias = "destination", skip_serializing_if = "Option::is_none")] - pub destination: Option, + pub destination: Option, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, #[serde(alias = "created_at")] - pub created_at: i64, + pub created_at: f64, #[serde(alias = "parts")] pub parts: u32, #[serde(alias = "amount_msat")] @@ -1818,13 +2067,18 @@ pub mod responses { /// Type of connection #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum ListnodesNodesAddressesType { + #[serde(rename = "dns")] DNS, + #[serde(rename = "ipv4")] IPV4, + #[serde(rename = "ipv6")] IPV6, + #[serde(rename = "torv2")] TORV2, + #[serde(rename = "torv3")] TORV3, + #[serde(rename = "websocket")] WEBSOCKET, } @@ -1856,7 +2110,7 @@ pub mod responses { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ListnodesNodes { #[serde(alias = "nodeid")] - pub nodeid: String, + pub nodeid: Pubkey, #[serde(alias = "last_timestamp", skip_serializing_if = "Option::is_none")] pub last_timestamp: Option, #[serde(alias = "alias", skip_serializing_if = "Option::is_none")] @@ -1865,8 +2119,8 @@ pub mod responses { pub color: Option, #[serde(alias = "features", skip_serializing_if = "Option::is_none")] pub features: Option, - #[serde(alias = "addresses")] - pub addresses: Vec, + #[serde(alias = "addresses", skip_serializing_if = "Option::is_none")] + pub addresses: Option>, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -1877,9 +2131,10 @@ pub mod responses { /// Whether it's paid or expired #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum WaitanyinvoiceStatus { + #[serde(rename = "paid")] PAID, + #[serde(rename = "expired")] EXPIRED, } @@ -1900,7 +2155,7 @@ pub mod responses { #[serde(alias = "description")] pub description: String, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, // Path `WaitAnyInvoice.status` #[serde(rename = "status")] pub status: WaitanyinvoiceStatus, @@ -1919,14 +2174,15 @@ pub mod responses { #[serde(alias = "paid_at", skip_serializing_if = "Option::is_none")] pub paid_at: Option, #[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")] - pub payment_preimage: Option, + pub payment_preimage: Option, } /// Whether it's paid or expired #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum WaitinvoiceStatus { + #[serde(rename = "paid")] PAID, + #[serde(rename = "expired")] EXPIRED, } @@ -1947,7 +2203,7 @@ pub mod responses { #[serde(alias = "description")] pub description: String, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, // Path `WaitInvoice.status` #[serde(rename = "status")] pub status: WaitinvoiceStatus, @@ -1966,13 +2222,13 @@ pub mod responses { #[serde(alias = "paid_at", skip_serializing_if = "Option::is_none")] pub paid_at: Option, #[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")] - pub payment_preimage: Option, + pub payment_preimage: Option, } /// status of the payment #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum WaitsendpayStatus { + #[serde(rename = "complete")] COMPLETE, } @@ -1992,14 +2248,14 @@ pub mod responses { #[serde(alias = "groupid", skip_serializing_if = "Option::is_none")] pub groupid: Option, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, // Path `WaitSendPay.status` #[serde(rename = "status")] pub status: WaitsendpayStatus, #[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")] pub amount_msat: Option, #[serde(alias = "destination", skip_serializing_if = "Option::is_none")] - pub destination: Option, + pub destination: Option, #[serde(alias = "created_at")] pub created_at: u64, #[serde(alias = "amount_sent_msat")] @@ -2013,7 +2269,7 @@ pub mod responses { #[serde(alias = "bolt12", skip_serializing_if = "Option::is_none")] pub bolt12: Option, #[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")] - pub payment_preimage: Option, + pub payment_preimage: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -2036,8 +2292,8 @@ pub mod responses { /// status of payment #[derive(Copy, Clone, Debug, Deserialize, Serialize)] - #[serde(rename_all = "lowercase")] pub enum KeysendStatus { + #[serde(rename = "complete")] COMPLETE, } @@ -2053,13 +2309,13 @@ pub mod responses { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct KeysendResponse { #[serde(alias = "payment_preimage")] - pub payment_preimage: String, + pub payment_preimage: Secret, #[serde(alias = "destination", skip_serializing_if = "Option::is_none")] - pub destination: Option, + pub destination: Option, #[serde(alias = "payment_hash")] - pub payment_hash: String, + pub payment_hash: Sha256, #[serde(alias = "created_at")] - pub created_at: i64, + pub created_at: f64, #[serde(alias = "parts")] pub parts: u32, #[serde(alias = "amount_msat")] @@ -2099,8 +2355,8 @@ pub mod responses { pub excess_msat: Amount, #[serde(alias = "change_outnum", skip_serializing_if = "Option::is_none")] pub change_outnum: Option, - #[serde(alias = "reservations")] - pub reservations: Vec, + #[serde(alias = "reservations", skip_serializing_if = "Option::is_none")] + pub reservations: Option>, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -2143,8 +2399,8 @@ pub mod responses { pub excess_msat: Amount, #[serde(alias = "change_outnum", skip_serializing_if = "Option::is_none")] pub change_outnum: Option, - #[serde(alias = "reservations")] - pub reservations: Vec, + #[serde(alias = "reservations", skip_serializing_if = "Option::is_none")] + pub reservations: Option>, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -2175,5 +2431,249 @@ pub mod responses { pub txid: String, } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct DisconnectResponse { + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct FeeratesPerkb { + #[serde(alias = "min_acceptable")] + pub min_acceptable: u32, + #[serde(alias = "max_acceptable")] + pub max_acceptable: u32, + #[serde(alias = "opening", skip_serializing_if = "Option::is_none")] + pub opening: Option, + #[serde(alias = "mutual_close", skip_serializing_if = "Option::is_none")] + pub mutual_close: Option, + #[serde(alias = "unilateral_close", skip_serializing_if = "Option::is_none")] + pub unilateral_close: Option, + #[serde(alias = "delayed_to_us", skip_serializing_if = "Option::is_none")] + pub delayed_to_us: Option, + #[serde(alias = "htlc_resolution", skip_serializing_if = "Option::is_none")] + pub htlc_resolution: Option, + #[serde(alias = "penalty", skip_serializing_if = "Option::is_none")] + pub penalty: Option, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct FeeratesPerkw { + #[serde(alias = "min_acceptable")] + pub min_acceptable: u32, + #[serde(alias = "max_acceptable")] + pub max_acceptable: u32, + #[serde(alias = "opening", skip_serializing_if = "Option::is_none")] + pub opening: Option, + #[serde(alias = "mutual_close", skip_serializing_if = "Option::is_none")] + pub mutual_close: Option, + #[serde(alias = "unilateral_close", skip_serializing_if = "Option::is_none")] + pub unilateral_close: Option, + #[serde(alias = "delayed_to_us", skip_serializing_if = "Option::is_none")] + pub delayed_to_us: Option, + #[serde(alias = "htlc_resolution", skip_serializing_if = "Option::is_none")] + pub htlc_resolution: Option, + #[serde(alias = "penalty", skip_serializing_if = "Option::is_none")] + pub penalty: Option, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct FeeratesOnchain_fee_estimates { + #[serde(alias = "opening_channel_satoshis")] + pub opening_channel_satoshis: u64, + #[serde(alias = "mutual_close_satoshis")] + pub mutual_close_satoshis: u64, + #[serde(alias = "unilateral_close_satoshis")] + pub unilateral_close_satoshis: u64, + #[serde(alias = "htlc_timeout_satoshis")] + pub htlc_timeout_satoshis: u64, + #[serde(alias = "htlc_success_satoshis")] + pub htlc_success_satoshis: u64, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct FeeratesResponse { + #[serde(alias = "warning_missing_feerates", skip_serializing_if = "Option::is_none")] + pub warning_missing_feerates: Option, + } + + /// The features understood by the destination node + #[derive(Copy, Clone, Debug, Deserialize, Serialize)] + pub enum GetrouteRouteStyle { + #[serde(rename = "tlv")] + TLV, + } + + impl TryFrom for GetrouteRouteStyle { + type Error = anyhow::Error; + fn try_from(c: i32) -> Result { + match c { + 0 => Ok(GetrouteRouteStyle::TLV), + o => Err(anyhow::anyhow!("Unknown variant {} for enum GetrouteRouteStyle", o)), + } + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct GetrouteRoute { + #[serde(alias = "id")] + pub id: Pubkey, + #[serde(alias = "channel")] + pub channel: ShortChannelId, + #[serde(alias = "direction")] + pub direction: u32, + #[serde(alias = "amount_msat")] + pub amount_msat: Amount, + #[serde(alias = "delay")] + pub delay: u32, + // Path `GetRoute.route[].style` + #[serde(rename = "style")] + pub style: GetrouteRouteStyle, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct GetrouteResponse { + #[serde(alias = "route")] + pub route: Vec, + } + + /// still ongoing, completed, failed locally, or failed after forwarding + #[derive(Copy, Clone, Debug, Deserialize, Serialize)] + pub enum ListforwardsForwardsStatus { + #[serde(rename = "offered")] + OFFERED, + #[serde(rename = "settled")] + SETTLED, + #[serde(rename = "local_failed")] + LOCAL_FAILED, + #[serde(rename = "failed")] + FAILED, + } + + impl TryFrom for ListforwardsForwardsStatus { + type Error = anyhow::Error; + fn try_from(c: i32) -> Result { + match c { + 0 => Ok(ListforwardsForwardsStatus::OFFERED), + 1 => Ok(ListforwardsForwardsStatus::SETTLED), + 2 => Ok(ListforwardsForwardsStatus::LOCAL_FAILED), + 3 => Ok(ListforwardsForwardsStatus::FAILED), + o => Err(anyhow::anyhow!("Unknown variant {} for enum ListforwardsForwardsStatus", o)), + } + } + } + /// Either a legacy onion format or a modern tlv format + #[derive(Copy, Clone, Debug, Deserialize, Serialize)] + pub enum ListforwardsForwardsStyle { + #[serde(rename = "legacy")] + LEGACY, + #[serde(rename = "tlv")] + TLV, + } + + impl TryFrom for ListforwardsForwardsStyle { + type Error = anyhow::Error; + fn try_from(c: i32) -> Result { + match c { + 0 => Ok(ListforwardsForwardsStyle::LEGACY), + 1 => Ok(ListforwardsForwardsStyle::TLV), + o => Err(anyhow::anyhow!("Unknown variant {} for enum ListforwardsForwardsStyle", o)), + } + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct ListforwardsForwards { + #[serde(alias = "in_channel")] + pub in_channel: ShortChannelId, + #[serde(alias = "in_msat")] + pub in_msat: Amount, + // Path `ListForwards.forwards[].status` + #[serde(rename = "status")] + pub status: ListforwardsForwardsStatus, + #[serde(alias = "received_time")] + pub received_time: f64, + #[serde(alias = "out_channel", skip_serializing_if = "Option::is_none")] + pub out_channel: Option, + #[serde(alias = "payment_hash", skip_serializing_if = "Option::is_none")] + pub payment_hash: Option, + pub style: Option, + #[serde(alias = "fee_msat", skip_serializing_if = "Option::is_none")] + pub fee_msat: Option, + #[serde(alias = "out_msat", skip_serializing_if = "Option::is_none")] + pub out_msat: Option, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct ListforwardsResponse { + #[serde(alias = "forwards")] + pub forwards: Vec, + } + + /// status of the payment + #[derive(Copy, Clone, Debug, Deserialize, Serialize)] + pub enum ListpaysPaysStatus { + #[serde(rename = "pending")] + PENDING, + #[serde(rename = "failed")] + FAILED, + #[serde(rename = "complete")] + COMPLETE, + } + + impl TryFrom for ListpaysPaysStatus { + type Error = anyhow::Error; + fn try_from(c: i32) -> Result { + match c { + 0 => Ok(ListpaysPaysStatus::PENDING), + 1 => Ok(ListpaysPaysStatus::FAILED), + 2 => Ok(ListpaysPaysStatus::COMPLETE), + o => Err(anyhow::anyhow!("Unknown variant {} for enum ListpaysPaysStatus", o)), + } + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct ListpaysPays { + #[serde(alias = "payment_hash")] + pub payment_hash: String, + // Path `ListPays.pays[].status` + #[serde(rename = "status")] + pub status: ListpaysPaysStatus, + #[serde(alias = "destination", skip_serializing_if = "Option::is_none")] + pub destination: Option, + #[serde(alias = "created_at")] + pub created_at: u64, + #[serde(alias = "label", skip_serializing_if = "Option::is_none")] + pub label: Option, + #[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")] + pub bolt11: Option, + #[serde(alias = "bolt12", skip_serializing_if = "Option::is_none")] + pub bolt12: Option, + #[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")] + pub amount_msat: Option, + #[serde(alias = "amount_sent_msat", skip_serializing_if = "Option::is_none")] + pub amount_sent_msat: Option, + #[serde(alias = "erroronion", skip_serializing_if = "Option::is_none")] + pub erroronion: Option, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct ListpaysResponse { + #[serde(alias = "pays")] + pub pays: Vec, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct PingResponse { + #[serde(alias = "totlen")] + pub totlen: u16, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct SignmessageResponse { + #[serde(alias = "signature")] + pub signature: String, + #[serde(alias = "recid")] + pub recid: String, + #[serde(alias = "zbase")] + pub zbase: String, + } + }