From d90aafeed6640c7a4fb30b415752c1ee46b91d3a Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 1 Apr 2022 14:42:45 +1030 Subject: [PATCH] cln-grpc: Add the `connect` method --- .msggen.json | 456 ++++++++++++++++--------- cln-grpc/proto/node.proto | Bin 8894 -> 10081 bytes cln-grpc/src/convert.rs | Bin 14366 -> 16775 bytes cln-grpc/src/pb.rs | 6 +- cln-grpc/src/server.rs | 90 +++++ cln-rpc/src/model.rs | Bin 28927 -> 33096 bytes contrib/msggen/msggen/__main__.py | 6 +- doc/schemas/datastore.request.json | 35 ++ doc/schemas/deldatastore.request.json | 20 ++ doc/schemas/listdatastore.request.json | 16 + 10 files changed, 458 insertions(+), 171 deletions(-) create mode 100644 doc/schemas/datastore.request.json create mode 100644 doc/schemas/deldatastore.request.json create mode 100644 doc/schemas/listdatastore.request.json diff --git a/.msggen.json b/.msggen.json index db8ab9dd7..df3be4bf6 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 d03b924275c83756a087305a84f72d5f6db8e01c..008f46b4110b7ea9c99a79013cb8d0c74b106a58 100644 GIT binary patch delta 1167 zcmb_bJx|+E6qSh(*b)UAM4+M06_rrJz(=4gsDg-iK!P+1bm@R)@Kvx#Y~%M*5k*lt zcC7Sfc19#K_b2o(REVF!K%cQ=$6#e*^E>yRd(QpvALYJs`#IGU9s3N*8r2B39L$Gb zHN0#gp#^Y|wj7hdV2Ie3Nw5H&uH^Hv5fbxdZ0P-Z2~}cI!rlw%t%!SI5ITe$3%mK$ z@~E)Rrp9MkH9hK@%=nBu^@?7aIU`)h=K%1yILd5S&2G+UF? z>_%Q-s@&r#|KzMtbRT6~V4^g!c-p2&fL_5DC~ixlWmCg4wFdNYLuZfh!My`%q$f3z z5Uq~U41=DbBZ;f45xmm0bd*FiTg?bOwC7># z9_DALUu$X*=mj4A>{7L=RLUIMh$n~mCda*>1C;eop7J*dTegjZ|9X- z?B<^DdWhbBg5IF@Sh2TsuO_>X9sR&@C5+2o;(*y0m;KGme-HnzaE}l|!|4&>O?EXA G>-IldB7~3t delta 108 zcmaFpx6gHhDf4D77FpKGkEDerD~NDycIKSG&uBFHii9ReXfwa067%Fq972=xr8y?c z%5ZKDk*Q~zT&yfOIZe)Ka<@F+WE1&%Mw7`&@>-kk$tN)~noo9A6lb&mk|J!GDGIg< KmYa(e6_@}hNgt{J diff --git a/cln-grpc/src/convert.rs b/cln-grpc/src/convert.rs index 0c2d78a2657ac2867c07cbb07ede8e4f32b437ff..bfc622aa0fe7082fa824cc320678228a2638c469 100644 GIT binary patch delta 873 zcmbPN(B90r;f3yGJ}qu#m&B69;*$KL)S%Sjg8aPVR6B*V{33;dBr7YJ)Z~vE>YOl6 z>f}NheXi`(N-KqAJs>stfs~dA4qK%;MRp(%RuKu!b`%=8p;^HWkmR)T1~+{6Nn z8jvk|B}J9-nRzAo8j}+RBylDwQIOjNz{wMlDpDr{9fX=JfNtVON+(#Hh2M(Fxdt4Z Xh(MXACym4d8qR|po|vYCf{+^kLn1tt delta 29 kcmZo~W}H{B;f3zzjmDx}+?h2BnF@);3Z;f-lLeW?0IJyux&QzG diff --git a/cln-grpc/src/pb.rs b/cln-grpc/src/pb.rs index 6d72730cf..0e5ba33ef 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 f492ed660..3b757c69d 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 a9494af746071deffe0433fed247767193bbb4cc..ddab41029b866fcbeb5e34d171b1b3b6b6d3f76d 100644 GIT binary patch delta 1588 zcmezWknuzl(}p7EdQO+blEmVY{GwEiqSV6D)Z&t2D=WBI5JX5*hl|rCH3u$?tTZ(z z1!e-0YM;#F5^Tyr;>hYZXEUoYp*o_tAV04-71b3GF)YqNC`NGyLOr@e;2Mxz!c>&H zxs7!{_v8!t+>@<^qw3)<_svg9RjB6TQ~(0s(BP1G=O9kbyRB^Co$AAD=KNqNGgi5$@Ef*JOW^O^wWvlrahnbC5zJ^4LPkTBPo601hU!T_ zm1sorocxeoK_WY~Qb{uw;<@gM$*B7J$sj3H)M{6U1322gKWOBgHE{EOZcp$3D!T tsgn(bBx&tY2M(CMAYZz|IH@R^2QCWELN-VRVo@sGwRXUw1XwNs5db8v4>14$ delta 45 zcmV+|0Mh@+f&%~H0kCodv-kra0<)tAv-+$1{xNVGj;NlXbC*CO?c%31APh# DvrrLC diff --git a/contrib/msggen/msggen/__main__.py b/contrib/msggen/msggen/__main__.py index b98b27f83..ee0819d88 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 000000000..d34db6770 --- /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 000000000..976425afb --- /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 000000000..d1693ab2b --- /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" + } + } + } +}