diff --git a/.msggen.json b/.msggen.json index db8ab9dd7e1b..df3be4bf6ce7 100644 --- a/.msggen.json +++ b/.msggen.json @@ -5,6 +5,24 @@ "unilateral": 1, "unopened": 2 }, + "ConnectAddressType": { + "ipv4": 1, + "ipv6": 2, + "local socket": 0, + "torv2": 3, + "torv3": 4 + }, + "ConnectDirection": { + "in": 0, + "out": 1 + }, + "DatastoreMode": { + "create-or-append": 4, + "create-or-replace": 2, + "must-append": 3, + "must-create": 0, + "must-replace": 1 + }, "GetinfoAddressType": { "dns": 0, "ipv4": 1, @@ -65,170 +83,278 @@ } }, "grpc-field-map": { - "AddGossip.message": 1, - "AutoCleanInvoice.cycle_seconds": 2, - "AutoCleanInvoice.enabled": 3, - "AutoCleanInvoice.expired_by": 1, - "CheckMessage.message": 1, - "CheckMessage.pubkey": 3, - "CheckMessage.verified": 4, - "CheckMessage.zbase": 2, - "Close.destination": 3, - "Close.fee_negotiation_step": 4, - "Close.force_lease_closed": 6, - "Close.id": 1, - "Close.tx": 8, - "Close.txid": 9, - "Close.type": 7, - "Close.unilateraltimeout": 2, - "Close.wrong_funding": 5, - "Getinfo.address[]": 14, - "Getinfo.address[].address": 3, - "Getinfo.address[].port": 2, - "Getinfo.address[].type": 1, - "Getinfo.alias": 2, - "Getinfo.binding[]": 15, - "Getinfo.binding[].address": 2, - "Getinfo.binding[].port": 3, - "Getinfo.binding[].socket": 4, - "Getinfo.binding[].type": 1, - "Getinfo.blockheight": 11, - "Getinfo.color": 3, - "Getinfo.fees_collected_msat": 13, - "Getinfo.id": 1, - "Getinfo.lightning-dir": 9, - "Getinfo.network": 12, - "Getinfo.num_active_channels": 6, - "Getinfo.num_inactive_channels": 7, - "Getinfo.num_peers": 4, - "Getinfo.num_pending_channels": 5, - "Getinfo.our_features": 10, - "Getinfo.our_features.channel": 3, - "Getinfo.our_features.init": 1, - "Getinfo.our_features.invoice": 4, - "Getinfo.our_features.node": 2, - "Getinfo.version": 8, - "Getinfo.warning_bitcoind_sync": 16, - "Getinfo.warning_lightningd_sync": 17, - "ListChannels.channels[]": 4, - "ListChannels.channels[].active": 8, - "ListChannels.channels[].amount_msat": 5, - "ListChannels.channels[].base_fee_millisatoshi": 10, - "ListChannels.channels[].channel_flags": 7, - "ListChannels.channels[].delay": 12, - "ListChannels.channels[].destination": 2, - "ListChannels.channels[].features": 15, - "ListChannels.channels[].fee_per_millionth": 11, - "ListChannels.channels[].htlc_maximum_msat": 14, - "ListChannels.channels[].htlc_minimum_msat": 13, - "ListChannels.channels[].last_update": 9, - "ListChannels.channels[].message_flags": 6, - "ListChannels.channels[].public": 4, - "ListChannels.channels[].short_channel_id": 3, - "ListChannels.channels[].source": 1, - "ListChannels.destination": 3, - "ListChannels.short_channel_id": 1, - "ListChannels.source": 2, - "ListFunds.channels[]": 3, - "ListFunds.channels[].amount_msat": 3, - "ListFunds.channels[].connected": 6, - "ListFunds.channels[].funding_output": 5, - "ListFunds.channels[].funding_txid": 4, - "ListFunds.channels[].our_amount_msat": 2, - "ListFunds.channels[].peer_id": 1, - "ListFunds.channels[].short_channel_id": 8, - "ListFunds.channels[].state": 7, - "ListFunds.outputs[]": 2, - "ListFunds.outputs[].address": 5, - "ListFunds.outputs[].amount_msat": 3, - "ListFunds.outputs[].blockheight": 8, - "ListFunds.outputs[].output": 2, - "ListFunds.outputs[].redeemscript": 6, - "ListFunds.outputs[].scriptpubkey": 4, - "ListFunds.outputs[].status": 7, - "ListFunds.outputs[].txid": 1, - "ListFunds.spent": 1, - "ListPeers.id": 1, - "ListPeers.level": 2, - "ListPeers.peers[]": 3, - "ListPeers.peers[].channels[]": 4, - "ListPeers.peers[].channels[].channel_id": 6, - "ListPeers.peers[].channels[].close_to": 14, - "ListPeers.peers[].channels[].close_to_addr": 47, - "ListPeers.peers[].channels[].closer": 17, - "ListPeers.peers[].channels[].dust_limit_msat": 26, - "ListPeers.peers[].channels[].features[]": 18, - "ListPeers.peers[].channels[].fee_base_msat": 24, - "ListPeers.peers[].channels[].fee_proportional_millionths": 25, - "ListPeers.peers[].channels[].feerate": 3, - "ListPeers.peers[].channels[].feerate.perkb": 2, - "ListPeers.peers[].channels[].feerate.perkw": 1, - "ListPeers.peers[].channels[].funding": 19, - "ListPeers.peers[].channels[].funding.local_msat": 1, - "ListPeers.peers[].channels[].funding.pushed_msat": 3, - "ListPeers.peers[].channels[].funding.remote_msat": 2, - "ListPeers.peers[].channels[].funding_outnum": 8, - "ListPeers.peers[].channels[].funding_txid": 7, - "ListPeers.peers[].channels[].htlcs[]": 46, - "ListPeers.peers[].channels[].htlcs[].amount_msat": 3, - "ListPeers.peers[].channels[].htlcs[].direction": 1, - "ListPeers.peers[].channels[].htlcs[].expiry": 4, - "ListPeers.peers[].channels[].htlcs[].id": 2, - "ListPeers.peers[].channels[].htlcs[].local_trimmed": 6, - "ListPeers.peers[].channels[].htlcs[].payment_hash": 5, - "ListPeers.peers[].channels[].htlcs[].state": 8, - "ListPeers.peers[].channels[].htlcs[].status": 7, - "ListPeers.peers[].channels[].in_fulfilled_msat": 41, - "ListPeers.peers[].channels[].in_offered_msat": 39, - "ListPeers.peers[].channels[].in_payments_fulfilled": 40, - "ListPeers.peers[].channels[].in_payments_offered": 38, - "ListPeers.peers[].channels[].inflight[]": 13, - "ListPeers.peers[].channels[].inflight[].feerate": 3, - "ListPeers.peers[].channels[].inflight[].funding_outnum": 2, - "ListPeers.peers[].channels[].inflight[].funding_txid": 1, - "ListPeers.peers[].channels[].inflight[].our_funding_msat": 5, - "ListPeers.peers[].channels[].inflight[].scratch_txid": 6, - "ListPeers.peers[].channels[].inflight[].total_funding_msat": 4, - "ListPeers.peers[].channels[].initial_feerate": 9, - "ListPeers.peers[].channels[].last_feerate": 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[].min_to_us_msat": 21, - "ListPeers.peers[].channels[].minimum_htlc_in_msat": 32, - "ListPeers.peers[].channels[].next_fee_step": 12, - "ListPeers.peers[].channels[].next_feerate": 11, - "ListPeers.peers[].channels[].opener": 16, - "ListPeers.peers[].channels[].our_reserve_msat": 29, - "ListPeers.peers[].channels[].our_to_self_delay": 34, - "ListPeers.peers[].channels[].out_fulfilled_msat": 45, - "ListPeers.peers[].channels[].out_offered_msat": 43, - "ListPeers.peers[].channels[].out_payments_fulfilled": 44, - "ListPeers.peers[].channels[].out_payments_offered": 42, - "ListPeers.peers[].channels[].owner": 4, - "ListPeers.peers[].channels[].private": 15, - "ListPeers.peers[].channels[].receivable_msat": 31, - "ListPeers.peers[].channels[].scratch_txid": 2, - "ListPeers.peers[].channels[].short_channel_id": 5, - "ListPeers.peers[].channels[].spendable_msat": 30, - "ListPeers.peers[].channels[].state": 1, - "ListPeers.peers[].channels[].state_changes[]": 36, - "ListPeers.peers[].channels[].status[]": 37, - "ListPeers.peers[].channels[].their_reserve_msat": 28, - "ListPeers.peers[].channels[].their_to_self_delay": 33, - "ListPeers.peers[].channels[].to_us_msat": 20, - "ListPeers.peers[].channels[].total_msat": 23, - "ListPeers.peers[].connected": 2, - "ListPeers.peers[].features": 6, - "ListPeers.peers[].id": 1, - "ListPeers.peers[].log[]": 3, - "ListPeers.peers[].log[].data": 7, - "ListPeers.peers[].log[].log": 5, - "ListPeers.peers[].log[].node_id": 6, - "ListPeers.peers[].log[].num_skipped": 2, - "ListPeers.peers[].log[].source": 4, - "ListPeers.peers[].log[].time": 3, - "ListPeers.peers[].log[].type": 1, - "ListPeers.peers[].netaddr[]": 5 + "AddgossipRequest": { + "AddGossip.message": 1 + }, + "AutocleaninvoiceRequest": { + "AutoCleanInvoice.cycle_seconds": 2, + "AutoCleanInvoice.expired_by": 1 + }, + "AutocleaninvoiceResponse": { + "AutoCleanInvoice.cycle_seconds": 3, + "AutoCleanInvoice.enabled": 1, + "AutoCleanInvoice.expired_by": 2 + }, + "CheckmessageRequest": { + "CheckMessage.message": 1, + "CheckMessage.pubkey": 3, + "CheckMessage.zbase": 2 + }, + "CheckmessageResponse": { + "CheckMessage.pubkey": 2, + "CheckMessage.verified": 1 + }, + "CloseRequest": { + "Close.destination": 3, + "Close.fee_negotiation_step": 4, + "Close.force_lease_closed": 6, + "Close.id": 1, + "Close.unilateraltimeout": 2, + "Close.wrong_funding": 5 + }, + "CloseResponse": { + "Close.tx": 2, + "Close.txid": 3, + "Close.type": 1 + }, + "ConnectAddress": { + "Connect.address.address": 3, + "Connect.address.port": 4, + "Connect.address.socket": 2, + "Connect.address.type": 1 + }, + "ConnectRequest": { + "Connect.host": 2, + "Connect.id": 1, + "Connect.port": 3 + }, + "ConnectResponse": { + "Connect.address": 4, + "Connect.direction": 3, + "Connect.features": 2, + "Connect.id": 1 + }, + "DatastoreRequest": { + "Datastore.generation": 4, + "Datastore.hex": 2, + "Datastore.key[]": 1, + "Datastore.mode": 3 + }, + "DatastoreResponse": { + "Datastore.generation": 2, + "Datastore.hex": 3, + "Datastore.key[]": 1, + "Datastore.string": 4 + }, + "DeldatastoreRequest": { + "DelDatastore.generation": 2, + "DelDatastore.key[]": 1 + }, + "DeldatastoreResponse": { + "DelDatastore.generation": 2, + "DelDatastore.hex": 3, + "DelDatastore.key[]": 1, + "DelDatastore.string": 4 + }, + "GetinfoAddress": { + "Getinfo.address[].address": 3, + "Getinfo.address[].port": 2, + "Getinfo.address[].type": 1 + }, + "GetinfoBinding": { + "Getinfo.binding[].address": 2, + "Getinfo.binding[].port": 3, + "Getinfo.binding[].socket": 4, + "Getinfo.binding[].type": 1 + }, + "GetinfoOur_features": { + "Getinfo.our_features.channel": 3, + "Getinfo.our_features.init": 1, + "Getinfo.our_features.invoice": 4, + "Getinfo.our_features.node": 2 + }, + "GetinfoResponse": { + "Getinfo.address[]": 14, + "Getinfo.alias": 2, + "Getinfo.binding[]": 15, + "Getinfo.blockheight": 11, + "Getinfo.color": 3, + "Getinfo.fees_collected_msat": 13, + "Getinfo.id": 1, + "Getinfo.lightning-dir": 9, + "Getinfo.network": 12, + "Getinfo.num_active_channels": 6, + "Getinfo.num_inactive_channels": 7, + "Getinfo.num_peers": 4, + "Getinfo.num_pending_channels": 5, + "Getinfo.our_features": 10, + "Getinfo.version": 8, + "Getinfo.warning_bitcoind_sync": 16, + "Getinfo.warning_lightningd_sync": 17 + }, + "ListchannelsChannels": { + "ListChannels.channels[].active": 8, + "ListChannels.channels[].amount_msat": 5, + "ListChannels.channels[].base_fee_millisatoshi": 10, + "ListChannels.channels[].channel_flags": 7, + "ListChannels.channels[].delay": 12, + "ListChannels.channels[].destination": 2, + "ListChannels.channels[].features": 15, + "ListChannels.channels[].fee_per_millionth": 11, + "ListChannels.channels[].htlc_maximum_msat": 14, + "ListChannels.channels[].htlc_minimum_msat": 13, + "ListChannels.channels[].last_update": 9, + "ListChannels.channels[].message_flags": 6, + "ListChannels.channels[].public": 4, + "ListChannels.channels[].short_channel_id": 3, + "ListChannels.channels[].source": 1 + }, + "ListchannelsRequest": { + "ListChannels.destination": 3, + "ListChannels.short_channel_id": 1, + "ListChannels.source": 2 + }, + "ListchannelsResponse": { + "ListChannels.channels[]": 1 + }, + "ListdatastoreDatastore": { + "ListDatastore.datastore[].generation": 2, + "ListDatastore.datastore[].hex": 3, + "ListDatastore.datastore[].key[]": 1, + "ListDatastore.datastore[].string": 4 + }, + "ListdatastoreRequest": { + "ListDatastore.key[]": 1 + }, + "ListdatastoreResponse": { + "ListDatastore.datastore[]": 1 + }, + "ListfundsChannels": { + "ListFunds.channels[].amount_msat": 3, + "ListFunds.channels[].connected": 6, + "ListFunds.channels[].funding_output": 5, + "ListFunds.channels[].funding_txid": 4, + "ListFunds.channels[].our_amount_msat": 2, + "ListFunds.channels[].peer_id": 1, + "ListFunds.channels[].short_channel_id": 8, + "ListFunds.channels[].state": 7 + }, + "ListfundsOutputs": { + "ListFunds.outputs[].address": 5, + "ListFunds.outputs[].amount_msat": 3, + "ListFunds.outputs[].blockheight": 8, + "ListFunds.outputs[].output": 2, + "ListFunds.outputs[].redeemscript": 6, + "ListFunds.outputs[].scriptpubkey": 4, + "ListFunds.outputs[].status": 7, + "ListFunds.outputs[].txid": 1 + }, + "ListfundsRequest": { + "ListFunds.spent": 1 + }, + "ListfundsResponse": { + "ListFunds.channels[]": 2, + "ListFunds.outputs[]": 1 + }, + "ListpeersPeers": { + "ListPeers.peers[].channels[]": 4, + "ListPeers.peers[].connected": 2, + "ListPeers.peers[].features": 6, + "ListPeers.peers[].id": 1, + "ListPeers.peers[].log[]": 3, + "ListPeers.peers[].netaddr[]": 5 + }, + "ListpeersPeersChannels": { + "ListPeers.peers[].channels[].channel_id": 6, + "ListPeers.peers[].channels[].close_to": 14, + "ListPeers.peers[].channels[].close_to_addr": 47, + "ListPeers.peers[].channels[].closer": 17, + "ListPeers.peers[].channels[].dust_limit_msat": 26, + "ListPeers.peers[].channels[].features[]": 18, + "ListPeers.peers[].channels[].fee_base_msat": 24, + "ListPeers.peers[].channels[].fee_proportional_millionths": 25, + "ListPeers.peers[].channels[].feerate": 3, + "ListPeers.peers[].channels[].funding": 19, + "ListPeers.peers[].channels[].funding_outnum": 8, + "ListPeers.peers[].channels[].funding_txid": 7, + "ListPeers.peers[].channels[].htlcs[]": 46, + "ListPeers.peers[].channels[].in_fulfilled_msat": 41, + "ListPeers.peers[].channels[].in_offered_msat": 39, + "ListPeers.peers[].channels[].in_payments_fulfilled": 40, + "ListPeers.peers[].channels[].in_payments_offered": 38, + "ListPeers.peers[].channels[].inflight[]": 13, + "ListPeers.peers[].channels[].initial_feerate": 9, + "ListPeers.peers[].channels[].last_feerate": 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[].min_to_us_msat": 21, + "ListPeers.peers[].channels[].minimum_htlc_in_msat": 32, + "ListPeers.peers[].channels[].next_fee_step": 12, + "ListPeers.peers[].channels[].next_feerate": 11, + "ListPeers.peers[].channels[].opener": 16, + "ListPeers.peers[].channels[].our_reserve_msat": 29, + "ListPeers.peers[].channels[].our_to_self_delay": 34, + "ListPeers.peers[].channels[].out_fulfilled_msat": 45, + "ListPeers.peers[].channels[].out_offered_msat": 43, + "ListPeers.peers[].channels[].out_payments_fulfilled": 44, + "ListPeers.peers[].channels[].out_payments_offered": 42, + "ListPeers.peers[].channels[].owner": 4, + "ListPeers.peers[].channels[].private": 15, + "ListPeers.peers[].channels[].receivable_msat": 31, + "ListPeers.peers[].channels[].scratch_txid": 2, + "ListPeers.peers[].channels[].short_channel_id": 5, + "ListPeers.peers[].channels[].spendable_msat": 30, + "ListPeers.peers[].channels[].state": 1, + "ListPeers.peers[].channels[].state_changes[]": 36, + "ListPeers.peers[].channels[].status[]": 37, + "ListPeers.peers[].channels[].their_reserve_msat": 28, + "ListPeers.peers[].channels[].their_to_self_delay": 33, + "ListPeers.peers[].channels[].to_us_msat": 20, + "ListPeers.peers[].channels[].total_msat": 23 + }, + "ListpeersPeersChannelsFeerate": { + "ListPeers.peers[].channels[].feerate.perkb": 2, + "ListPeers.peers[].channels[].feerate.perkw": 1 + }, + "ListpeersPeersChannelsFunding": { + "ListPeers.peers[].channels[].funding.local_msat": 1, + "ListPeers.peers[].channels[].funding.pushed_msat": 3, + "ListPeers.peers[].channels[].funding.remote_msat": 2 + }, + "ListpeersPeersChannelsHtlcs": { + "ListPeers.peers[].channels[].htlcs[].amount_msat": 3, + "ListPeers.peers[].channels[].htlcs[].direction": 1, + "ListPeers.peers[].channels[].htlcs[].expiry": 4, + "ListPeers.peers[].channels[].htlcs[].id": 2, + "ListPeers.peers[].channels[].htlcs[].local_trimmed": 6, + "ListPeers.peers[].channels[].htlcs[].payment_hash": 5, + "ListPeers.peers[].channels[].htlcs[].state": 8, + "ListPeers.peers[].channels[].htlcs[].status": 7 + }, + "ListpeersPeersChannelsInflight": { + "ListPeers.peers[].channels[].inflight[].feerate": 3, + "ListPeers.peers[].channels[].inflight[].funding_outnum": 2, + "ListPeers.peers[].channels[].inflight[].funding_txid": 1, + "ListPeers.peers[].channels[].inflight[].our_funding_msat": 5, + "ListPeers.peers[].channels[].inflight[].scratch_txid": 6, + "ListPeers.peers[].channels[].inflight[].total_funding_msat": 4 + }, + "ListpeersPeersLog": { + "ListPeers.peers[].log[].data": 7, + "ListPeers.peers[].log[].log": 5, + "ListPeers.peers[].log[].node_id": 6, + "ListPeers.peers[].log[].num_skipped": 2, + "ListPeers.peers[].log[].source": 4, + "ListPeers.peers[].log[].time": 3, + "ListPeers.peers[].log[].type": 1 + }, + "ListpeersRequest": { + "ListPeers.id": 1, + "ListPeers.level": 2 + }, + "ListpeersResponse": { + "ListPeers.peers[]": 1 + } } } \ No newline at end of file diff --git a/cln-grpc/proto/node.proto b/cln-grpc/proto/node.proto index d03b924275c8..008f46b4110b 100644 --- a/cln-grpc/proto/node.proto +++ b/cln-grpc/proto/node.proto @@ -17,6 +17,9 @@ service Node { rpc CheckMessage(CheckmessageRequest) returns (CheckmessageResponse) {} rpc Close(CloseRequest) returns (CloseResponse) {} rpc ConnectPeer(ConnectRequest) returns (ConnectResponse) {} + rpc Datastore(DatastoreRequest) returns (DatastoreResponse) {} + rpc DelDatastore(DeldatastoreRequest) returns (DeldatastoreResponse) {} + rpc ListDatastore(ListdatastoreRequest) returns (ListdatastoreResponse) {} } message GetinfoRequest { @@ -84,7 +87,7 @@ message ListpeersRequest { } message ListpeersResponse { - repeated ListpeersPeers peers = 3; + repeated ListpeersPeers peers = 1; } message ListpeersPeers { @@ -231,8 +234,8 @@ message ListfundsRequest { } message ListfundsResponse { - repeated ListfundsOutputs outputs = 2; - repeated ListfundsChannels channels = 3; + repeated ListfundsOutputs outputs = 1; + repeated ListfundsChannels channels = 2; } message ListfundsOutputs { @@ -270,7 +273,7 @@ message ListchannelsRequest { } message ListchannelsResponse { - repeated ListchannelsChannels channels = 4; + repeated ListchannelsChannels channels = 1; } message ListchannelsChannels { @@ -304,9 +307,9 @@ message AutocleaninvoiceRequest { } message AutocleaninvoiceResponse { - bool enabled = 3; - optional uint64 expired_by = 1; - optional uint64 cycle_seconds = 2; + bool enabled = 1; + optional uint64 expired_by = 2; + optional uint64 cycle_seconds = 3; } message CheckmessageRequest { @@ -316,8 +319,8 @@ message CheckmessageRequest { } message CheckmessageResponse { - bool verified = 4; - optional bytes pubkey = 3; + bool verified = 1; + optional bytes pubkey = 2; } message CloseRequest { @@ -336,9 +339,9 @@ message CloseResponse { UNILATERAL = 1; UNOPENED = 2; } - CloseType item_type = 7; - optional bytes tx = 8; - optional bytes txid = 9; + CloseType item_type = 1; + optional bytes tx = 2; + optional bytes txid = 3; } message ConnectRequest { @@ -372,3 +375,52 @@ message ConnectAddress { optional string address = 3; optional uint32 port = 4; } + +message DatastoreRequest { + // Datastore.mode + enum DatastoreMode { + MUST_CREATE = 0; + MUST_REPLACE = 1; + CREATE_OR_REPLACE = 2; + MUST_APPEND = 3; + CREATE_OR_APPEND = 4; + } + repeated string key = 1; + optional bytes hex = 2; + optional DatastoreMode mode = 3; + optional uint64 generation = 4; +} + +message DatastoreResponse { + repeated string key = 1; + optional uint64 generation = 2; + optional bytes hex = 3; + optional string string = 4; +} + +message DeldatastoreRequest { + repeated string key = 1; + optional uint64 generation = 2; +} + +message DeldatastoreResponse { + repeated string key = 1; + optional uint64 generation = 2; + optional bytes hex = 3; + optional string string = 4; +} + +message ListdatastoreRequest { + repeated string key = 1; +} + +message ListdatastoreResponse { + repeated ListdatastoreDatastore datastore = 1; +} + +message ListdatastoreDatastore { + repeated string key = 1; + optional uint64 generation = 2; + optional bytes hex = 3; + optional string string = 4; +} diff --git a/cln-grpc/src/convert.rs b/cln-grpc/src/convert.rs index 0c2d78a2657a..bfc622aa0fe7 100644 --- a/cln-grpc/src/convert.rs +++ b/cln-grpc/src/convert.rs @@ -300,6 +300,51 @@ impl From<&responses::ConnectResponse> for pb::ConnectResponse { } } +#[allow(unused_variables)] +impl From<&responses::DatastoreResponse> for pb::DatastoreResponse { + fn from(c: &responses::DatastoreResponse) -> Self { + Self { + key: c.key.iter().map(|s| s.into()).collect(), + generation: c.generation.clone(), + hex: c.hex.as_ref().map(|v| hex::decode(&v).unwrap()), + string: c.string.clone(), + } + } +} + +#[allow(unused_variables)] +impl From<&responses::DeldatastoreResponse> for pb::DeldatastoreResponse { + fn from(c: &responses::DeldatastoreResponse) -> Self { + Self { + key: c.key.iter().map(|s| s.into()).collect(), + generation: c.generation.clone(), + hex: c.hex.as_ref().map(|v| hex::decode(&v).unwrap()), + string: c.string.clone(), + } + } +} + +#[allow(unused_variables)] +impl From<&responses::ListdatastoreDatastore> for pb::ListdatastoreDatastore { + fn from(c: &responses::ListdatastoreDatastore) -> Self { + Self { + key: c.key.iter().map(|s| s.into()).collect(), + generation: c.generation.clone(), + hex: c.hex.as_ref().map(|v| hex::decode(&v).unwrap()), + string: c.string.clone(), + } + } +} + +#[allow(unused_variables)] +impl From<&responses::ListdatastoreResponse> for pb::ListdatastoreResponse { + fn from(c: &responses::ListdatastoreResponse) -> Self { + Self { + datastore: c.datastore.iter().map(|s| s.into()).collect(), + } + } +} + #[allow(unused_variables)] impl From<&pb::GetinfoRequest> for requests::GetinfoRequest { fn from(c: &pb::GetinfoRequest) -> Self { @@ -388,7 +433,38 @@ impl From<&pb::ConnectRequest> for requests::ConnectRequest { Self { id: hex::encode(&c.id), host: c.host.clone(), - port: c.port.map(|i| i as u16), + port: c.port.map(|v| v as u16), + } + } +} + +#[allow(unused_variables)] +impl From<&pb::DatastoreRequest> for requests::DatastoreRequest { + fn from(c: &pb::DatastoreRequest) -> Self { + Self { + key: c.key.iter().map(|s| s.into()).collect(), + hex: c.hex.clone().map(|v| hex::encode(v)), + mode: c.mode.map(|v| v.try_into().unwrap()), + generation: c.generation.clone(), + } + } +} + +#[allow(unused_variables)] +impl From<&pb::DeldatastoreRequest> for requests::DeldatastoreRequest { + fn from(c: &pb::DeldatastoreRequest) -> Self { + Self { + key: c.key.iter().map(|s| s.into()).collect(), + generation: c.generation.clone(), + } + } +} + +#[allow(unused_variables)] +impl From<&pb::ListdatastoreRequest> for requests::ListdatastoreRequest { + fn from(c: &pb::ListdatastoreRequest) -> Self { + Self { + key: c.key.iter().map(|s| s.into()).collect(), } } } diff --git a/cln-grpc/src/pb.rs b/cln-grpc/src/pb.rs index 6d72730cf864..0e5ba33ef8ab 100644 --- a/cln-grpc/src/pb.rs +++ b/cln-grpc/src/pb.rs @@ -8,8 +8,8 @@ impl From for Amount { } } -impl From for JAmount { - fn from(a: Amount) -> Self { - JAmount::from_msat(a.msat) +impl From<&Amount> for JAmount { + fn from(a: &Amount) -> Self { + JAmount::from_msat(a.msat) } } diff --git a/cln-grpc/src/server.rs b/cln-grpc/src/server.rs index f492ed660086..3b757c69daf8 100644 --- a/cln-grpc/src/server.rs +++ b/cln-grpc/src/server.rs @@ -296,4 +296,94 @@ async fn connect_peer( } +async fn datastore( + &self, + request: tonic::Request, +) -> Result, tonic::Status> { + let req = request.into_inner(); + let req: requests::DatastoreRequest = (&req).into(); + debug!("Client asked for getinfo"); + let mut rpc = ClnRpc::new(&self.rpc_path) + .await + .map_err(|e| Status::new(Code::Internal, e.to_string()))?; + let result = rpc.call(Request::Datastore(req)) + .await + .map_err(|e| Status::new( + Code::Unknown, + format!("Error calling method Datastore: {:?}", e)))?; + match result { + Response::Datastore(r) => Ok( + tonic::Response::new((&r).into()) + ), + r => Err(Status::new( + Code::Internal, + format!( + "Unexpected result {:?} to method call Datastore", + r + ) + )), + } + +} + +async fn del_datastore( + &self, + request: tonic::Request, +) -> Result, tonic::Status> { + let req = request.into_inner(); + let req: requests::DeldatastoreRequest = (&req).into(); + debug!("Client asked for getinfo"); + let mut rpc = ClnRpc::new(&self.rpc_path) + .await + .map_err(|e| Status::new(Code::Internal, e.to_string()))?; + let result = rpc.call(Request::DelDatastore(req)) + .await + .map_err(|e| Status::new( + Code::Unknown, + format!("Error calling method DelDatastore: {:?}", e)))?; + match result { + Response::DelDatastore(r) => Ok( + tonic::Response::new((&r).into()) + ), + r => Err(Status::new( + Code::Internal, + format!( + "Unexpected result {:?} to method call DelDatastore", + r + ) + )), + } + +} + +async fn list_datastore( + &self, + request: tonic::Request, +) -> Result, tonic::Status> { + let req = request.into_inner(); + let req: requests::ListdatastoreRequest = (&req).into(); + debug!("Client asked for getinfo"); + let mut rpc = ClnRpc::new(&self.rpc_path) + .await + .map_err(|e| Status::new(Code::Internal, e.to_string()))?; + let result = rpc.call(Request::ListDatastore(req)) + .await + .map_err(|e| Status::new( + Code::Unknown, + format!("Error calling method ListDatastore: {:?}", e)))?; + match result { + Response::ListDatastore(r) => Ok( + tonic::Response::new((&r).into()) + ), + r => Err(Status::new( + Code::Internal, + format!( + "Unexpected result {:?} to method call ListDatastore", + r + ) + )), + } + +} + } diff --git a/cln-rpc/src/model.rs b/cln-rpc/src/model.rs index a9494af74607..ddab41029b86 100644 --- a/cln-rpc/src/model.rs +++ b/cln-rpc/src/model.rs @@ -25,6 +25,9 @@ pub enum Request { CheckMessage(requests::CheckmessageRequest), Close(requests::CloseRequest), ConnectPeer(requests::ConnectRequest), + Datastore(requests::DatastoreRequest), + DelDatastore(requests::DeldatastoreRequest), + ListDatastore(requests::ListdatastoreRequest), } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -40,6 +43,9 @@ pub enum Response { CheckMessage(responses::CheckmessageResponse), Close(responses::CloseResponse), ConnectPeer(responses::ConnectResponse), + Datastore(responses::DatastoreResponse), + DelDatastore(responses::DeldatastoreResponse), + ListDatastore(responses::ListdatastoreResponse), } pub mod requests { @@ -126,6 +132,54 @@ pub mod requests { pub port: Option, } + #[derive(Copy, Clone, Debug, Deserialize, Serialize)] + #[serde(rename_all = "lowercase")] + pub enum DatastoreMode { + MUST_CREATE, + MUST_REPLACE, + CREATE_OR_REPLACE, + MUST_APPEND, + CREATE_OR_APPEND, + } + + impl TryFrom for DatastoreMode { + type Error = anyhow::Error; + fn try_from(c: i32) -> Result { + match c { + 0 => Ok(DatastoreMode::MUST_CREATE), + 1 => Ok(DatastoreMode::MUST_REPLACE), + 2 => Ok(DatastoreMode::CREATE_OR_REPLACE), + 3 => Ok(DatastoreMode::MUST_APPEND), + 4 => Ok(DatastoreMode::CREATE_OR_APPEND), + o => Err(anyhow::anyhow!("Unknown variant {} for enum DatastoreMode", o)), + } + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct DatastoreRequest { + #[serde(alias = "key")] + pub key: Vec, + #[serde(alias = "hex", skip_serializing_if = "Option::is_none")] + pub hex: Option, + pub mode: Option, + #[serde(alias = "generation", skip_serializing_if = "Option::is_none")] + pub generation: Option, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct DeldatastoreRequest { + #[serde(alias = "key")] + pub key: Vec, + #[serde(alias = "generation", skip_serializing_if = "Option::is_none")] + pub generation: Option, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct ListdatastoreRequest { + #[serde(alias = "key")] + pub key: Vec, + } + } @@ -751,6 +805,16 @@ pub mod responses { OUT, } + impl TryFrom for ConnectDirection { + type Error = anyhow::Error; + fn try_from(c: i32) -> Result { + match c { + 0 => Ok(ConnectDirection::IN), + 1 => Ok(ConnectDirection::OUT), + o => Err(anyhow::anyhow!("Unknown variant {} for enum ConnectDirection", o)), + } + } + } /// Type of connection (*torv2*/*torv3* only if **direction** is *out*) #[derive(Copy, Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] @@ -762,6 +826,19 @@ pub mod responses { TORV3, } + impl TryFrom for ConnectAddressType { + type Error = anyhow::Error; + fn try_from(c: i32) -> Result { + match c { + 0 => Ok(ConnectAddressType::LOCAL_SOCKET), + 1 => Ok(ConnectAddressType::IPV4), + 2 => Ok(ConnectAddressType::IPV6), + 3 => Ok(ConnectAddressType::TORV2), + 4 => Ok(ConnectAddressType::TORV3), + o => Err(anyhow::anyhow!("Unknown variant {} for enum ConnectAddressType", o)), + } + } + } #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ConnectAddress { // Path `Connect.address.type` @@ -786,5 +863,47 @@ pub mod responses { pub direction: ConnectDirection, } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct DatastoreResponse { + #[serde(alias = "key")] + pub key: Vec, + #[serde(alias = "generation", skip_serializing_if = "Option::is_none")] + pub generation: Option, + #[serde(alias = "hex", skip_serializing_if = "Option::is_none")] + pub hex: Option, + #[serde(alias = "string", skip_serializing_if = "Option::is_none")] + pub string: Option, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct DeldatastoreResponse { + #[serde(alias = "key")] + pub key: Vec, + #[serde(alias = "generation", skip_serializing_if = "Option::is_none")] + pub generation: Option, + #[serde(alias = "hex", skip_serializing_if = "Option::is_none")] + pub hex: Option, + #[serde(alias = "string", skip_serializing_if = "Option::is_none")] + pub string: Option, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct ListdatastoreDatastore { + #[serde(alias = "key")] + pub key: Vec, + #[serde(alias = "generation", skip_serializing_if = "Option::is_none")] + pub generation: Option, + #[serde(alias = "hex", skip_serializing_if = "Option::is_none")] + pub hex: Option, + #[serde(alias = "string", skip_serializing_if = "Option::is_none")] + pub string: Option, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct ListdatastoreResponse { + #[serde(alias = "datastore")] + pub datastore: Vec, + } + } diff --git a/contrib/msggen/msggen/__main__.py b/contrib/msggen/msggen/__main__.py index b98b27f83493..ee0819d88fa0 100644 --- a/contrib/msggen/msggen/__main__.py +++ b/contrib/msggen/msggen/__main__.py @@ -53,10 +53,10 @@ def load_jsonrpc_service(): "Connect", # "createinvoice", # "createonion", - # "datastore", + "Datastore", # "decodepay", # "decode", - # "deldatastore", + "DelDatastore", # "delexpiredinvoice", # "delinvoice", # "delpay", @@ -79,7 +79,7 @@ def load_jsonrpc_service(): # "keysend", # "listchannels", # "listconfigs", - # "listdatastore", + "ListDatastore", # "listforwards", # "listfunds", # "listinvoices", diff --git a/doc/schemas/datastore.request.json b/doc/schemas/datastore.request.json new file mode 100644 index 000000000000..d34db677064a --- /dev/null +++ b/doc/schemas/datastore.request.json @@ -0,0 +1,35 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": [ + "key" + ], + "properties": { + "key": { + "type": "array", + "description": "key is an array of values (though a single value is treated as a one-element array), to form a heirarchy. Using the first element of the key as the plugin name (e.g. [ 'summary' ]) is recommended. A key can either have children or a value, never both: parents are created and removed automatically.", + "items": { + "type": "string" + } + }, + "hex": { + "type": "hex", + "description": "" + }, + "mode": { + "type": "string", + "enum": [ + "must-create", + "must-replace", + "create-or-replace", + "must-append", + "create-or-append" + ], + "description": "" + }, + "generation": { + "type": "u64", + "description": "If specified, means that the update will fail if the previously-existing data is not exactly that generation. This allows for simple atomicity. This is only legal with mode “must-replace” or “must-append”." + } + } +} diff --git a/doc/schemas/deldatastore.request.json b/doc/schemas/deldatastore.request.json new file mode 100644 index 000000000000..976425afbe9a --- /dev/null +++ b/doc/schemas/deldatastore.request.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": [ + "key" + ], + "properties": { + "key": { + "type": "array", + "description": "key is an array of values (though a single value is treated as a one-element array), to form a heirarchy. Using the first element of the key as the plugin name (e.g. [ 'summary' ]) is recommended. A key can either have children or a value, never both: parents are created and removed automatically.", + "items": { + "type": "string" + } + }, + "generation": { + "type": "u64", + "description": "If specified, means that the update will fail if the previously-existing data is not exactly that generation. This allows for simple atomicity. This is only legal with mode “must-replace” or “must-append”." + } + } +} diff --git a/doc/schemas/listdatastore.request.json b/doc/schemas/listdatastore.request.json new file mode 100644 index 000000000000..d1693ab2bed4 --- /dev/null +++ b/doc/schemas/listdatastore.request.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": [ + "key" + ], + "properties": { + "key": { + "type": "array", + "description": "key is an array of values (though a single value is treated as a one-element array), to form a heirarchy. Using the first element of the key as the plugin name (e.g. [ 'summary' ]) is recommended. A key can either have children or a value, never both: parents are created and removed automatically.", + "items": { + "type": "string" + } + } + } +}