grpc: Map sendonion and createonion

This commit is contained in:
Christian Decker
2022-04-01 14:42:45 +10:30
committed by Rusty Russell
parent 565518246a
commit 20704746bc
28 changed files with 3031 additions and 243 deletions

View File

@@ -48,6 +48,9 @@
"torv2": 3,
"torv3": 4
},
"KeysendStatus": {
"complete": 0
},
"ListfundsOutputsStatus": {
"confirmed": 1,
"spent": 2,
@@ -58,6 +61,14 @@
"paid": 1,
"unpaid": 0
},
"ListnodesNodesAddressesType": {
"dns": 0,
"ipv4": 1,
"ipv6": 2,
"torv2": 3,
"torv3": 4,
"websocket": 5
},
"ListpeersPeersChannelsHtlcsDirection": {
"in": 0,
"out": 1
@@ -95,6 +106,70 @@
"IO_OUT": 6,
"SKIPPED": 0,
"UNUSUAL": 2
},
"ListsendpaysPaymentsStatus": {
"complete": 2,
"failed": 1,
"pending": 0
},
"ListsendpaysStatus": {
"complete": 1,
"failed": 2,
"pending": 0
},
"ListtransactionsTransactionsInputsType": {
"channel_funding": 3,
"channel_htlc_success": 7,
"channel_htlc_timeout": 8,
"channel_mutual_close": 4,
"channel_penalty": 9,
"channel_sweep": 6,
"channel_unilateral_cheat": 10,
"channel_unilateral_close": 5,
"deposit": 1,
"theirs": 0,
"withdraw": 2
},
"ListtransactionsTransactionsOutputsType": {
"channel_funding": 3,
"channel_htlc_success": 7,
"channel_htlc_timeout": 8,
"channel_mutual_close": 4,
"channel_penalty": 9,
"channel_sweep": 6,
"channel_unilateral_cheat": 10,
"channel_unilateral_close": 5,
"deposit": 1,
"theirs": 0,
"withdraw": 2
},
"NewaddrAddresstype": {
"bech32": 0,
"p2sh-segwit": 1
},
"PayStatus": {
"complete": 0,
"failed": 2,
"pending": 1
},
"SendonionStatus": {
"complete": 1,
"pending": 0
},
"SendpayStatus": {
"complete": 1,
"pending": 0
},
"WaitanyinvoiceStatus": {
"expired": 1,
"paid": 0
},
"WaitinvoiceStatus": {
"expired": 1,
"paid": 0
},
"WaitsendpayStatus": {
"complete": 0
}
},
"grpc-field-map": {
@@ -170,6 +245,20 @@
"CreateInvoice.payment_preimage": 12,
"CreateInvoice.status": 6
},
"CreateonionHops": {
"CreateOnion.hops[].payload": 2,
"CreateOnion.hops[].pubkey": 1
},
"CreateonionRequest": {
"CreateOnion.assocdata": 2,
"CreateOnion.hops[]": 1,
"CreateOnion.onion_size": 4,
"CreateOnion.session_key": 3
},
"CreateonionResponse": {
"CreateOnion.onion": 1,
"CreateOnion.shared_secrets[]": 2
},
"DatastoreRequest": {
"Datastore.generation": 4,
"Datastore.hex": 2,
@@ -266,6 +355,26 @@
"Invoice.warning_offline": 6,
"Invoice.warning_private_unused": 8
},
"KeysendRequest": {
"KeySend.destination": 1,
"KeySend.exemptfee": 7,
"KeySend.label": 3,
"KeySend.maxdelay": 6,
"KeySend.maxfeepercent": 4,
"KeySend.msatoshi": 2,
"KeySend.retry_for": 5
},
"KeysendResponse": {
"KeySend.amount_msat": 6,
"KeySend.amount_sent_msat": 7,
"KeySend.created_at": 4,
"KeySend.destination": 2,
"KeySend.parts": 5,
"KeySend.payment_hash": 3,
"KeySend.payment_preimage": 1,
"KeySend.status": 9,
"KeySend.warning_partial_completion": 8
},
"ListchannelsChannels": {
"ListChannels.channels[].active": 8,
"ListChannels.channels[].amount_msat": 5,
@@ -355,6 +464,25 @@
"ListinvoicesResponse": {
"ListInvoices.invoices[]": 1
},
"ListnodesNodes": {
"ListNodes.nodes[].addresses[]": 6,
"ListNodes.nodes[].alias": 3,
"ListNodes.nodes[].color": 4,
"ListNodes.nodes[].features": 5,
"ListNodes.nodes[].last_timestamp": 2,
"ListNodes.nodes[].nodeid": 1
},
"ListnodesNodesAddresses": {
"ListNodes.nodes[].addresses[].address": 3,
"ListNodes.nodes[].addresses[].port": 2,
"ListNodes.nodes[].addresses[].type": 1
},
"ListnodesRequest": {
"ListNodes.id": 1
},
"ListnodesResponse": {
"ListNodes.nodes[]": 1
},
"ListpeersPeers": {
"ListPeers.peers[].channels[]": 4,
"ListPeers.peers[].connected": 2,
@@ -454,6 +582,206 @@
},
"ListpeersResponse": {
"ListPeers.peers[]": 1
},
"ListsendpaysPayments": {
"ListSendPays.payments[].amount_msat": 5,
"ListSendPays.payments[].amount_sent_msat": 8,
"ListSendPays.payments[].bolt11": 10,
"ListSendPays.payments[].bolt12": 11,
"ListSendPays.payments[].created_at": 7,
"ListSendPays.payments[].destination": 6,
"ListSendPays.payments[].erroronion": 13,
"ListSendPays.payments[].groupid": 2,
"ListSendPays.payments[].id": 1,
"ListSendPays.payments[].label": 9,
"ListSendPays.payments[].payment_hash": 3,
"ListSendPays.payments[].payment_preimage": 12,
"ListSendPays.payments[].status": 4
},
"ListsendpaysRequest": {
"ListSendPays.bolt11": 1,
"ListSendPays.payment_hash": 2,
"ListSendPays.status": 3
},
"ListsendpaysResponse": {
"ListSendPays.payments[]": 1
},
"ListtransactionsResponse": {
"ListTransactions.transactions[]": 1
},
"ListtransactionsTransactions": {
"ListTransactions.transactions[].blockheight": 3,
"ListTransactions.transactions[].channel": 6,
"ListTransactions.transactions[].hash": 1,
"ListTransactions.transactions[].inputs[]": 9,
"ListTransactions.transactions[].locktime": 7,
"ListTransactions.transactions[].outputs[]": 10,
"ListTransactions.transactions[].rawtx": 2,
"ListTransactions.transactions[].txindex": 4,
"ListTransactions.transactions[].type[]": 5,
"ListTransactions.transactions[].version": 8
},
"ListtransactionsTransactionsInputs": {
"ListTransactions.transactions[].inputs[].channel": 5,
"ListTransactions.transactions[].inputs[].index": 2,
"ListTransactions.transactions[].inputs[].sequence": 3,
"ListTransactions.transactions[].inputs[].txid": 1,
"ListTransactions.transactions[].inputs[].type": 4
},
"ListtransactionsTransactionsOutputs": {
"ListTransactions.transactions[].outputs[].channel": 5,
"ListTransactions.transactions[].outputs[].index": 1,
"ListTransactions.transactions[].outputs[].msat": 2,
"ListTransactions.transactions[].outputs[].scriptPubKey": 3,
"ListTransactions.transactions[].outputs[].type": 4
},
"NewaddrRequest": {
"NewAddr.addresstype": 1
},
"NewaddrResponse": {
"NewAddr.bech32": 1,
"NewAddr.p2sh-segwit": 2
},
"PayRequest": {
"Pay.bolt11": 1,
"Pay.exemptfee": 7,
"Pay.label": 3,
"Pay.maxdelay": 6,
"Pay.maxfeepercent": 4,
"Pay.msatoshi": 2,
"Pay.retry_for": 5,
"Pay.riskfactor": 8
},
"PayResponse": {
"Pay.amount_msat": 6,
"Pay.amount_sent_msat": 7,
"Pay.created_at": 4,
"Pay.destination": 2,
"Pay.parts": 5,
"Pay.payment_hash": 3,
"Pay.payment_preimage": 1,
"Pay.status": 9,
"Pay.warning_partial_completion": 8
},
"SendonionFirst_hop": {
"SendOnion.first_hop.amount_msat": 2,
"SendOnion.first_hop.delay": 3,
"SendOnion.first_hop.id": 1
},
"SendonionRequest": {
"SendOnion.first_hop": 2,
"SendOnion.onion": 1
},
"SendonionResponse": {
"SendOnion.amount_msat": 4,
"SendOnion.amount_sent_msat": 7,
"SendOnion.bolt11": 9,
"SendOnion.bolt12": 10,
"SendOnion.created_at": 6,
"SendOnion.destination": 5,
"SendOnion.id": 1,
"SendOnion.label": 8,
"SendOnion.message": 12,
"SendOnion.payment_hash": 2,
"SendOnion.payment_preimage": 11,
"SendOnion.status": 3
},
"SendpayRequest": {
"SendPay.bolt11": 5,
"SendPay.label": 3,
"SendPay.msatoshi": 4,
"SendPay.partid": 7,
"SendPay.payment_hash": 2,
"SendPay.payment_secret": 6,
"SendPay.route[]": 1
},
"SendpayResponse": {
"SendPay.amount_msat": 5,
"SendPay.amount_sent_msat": 8,
"SendPay.bolt11": 11,
"SendPay.bolt12": 12,
"SendPay.created_at": 7,
"SendPay.destination": 6,
"SendPay.groupid": 2,
"SendPay.id": 1,
"SendPay.label": 9,
"SendPay.message": 14,
"SendPay.partid": 10,
"SendPay.payment_hash": 3,
"SendPay.payment_preimage": 13,
"SendPay.status": 4
},
"SendpayRoute": {
"SendPay.route[].channel": 4,
"SendPay.route[].delay": 3,
"SendPay.route[].id": 2,
"SendPay.route[].msatoshi": 1
},
"WaitanyinvoiceRequest": {
"WaitAnyInvoice.lastpay_index": 1,
"WaitAnyInvoice.timeout": 2
},
"WaitanyinvoiceResponse": {
"WaitAnyInvoice.amount_msat": 6,
"WaitAnyInvoice.amount_received_msat": 10,
"WaitAnyInvoice.bolt11": 7,
"WaitAnyInvoice.bolt12": 8,
"WaitAnyInvoice.description": 2,
"WaitAnyInvoice.expires_at": 5,
"WaitAnyInvoice.label": 1,
"WaitAnyInvoice.paid_at": 11,
"WaitAnyInvoice.pay_index": 9,
"WaitAnyInvoice.payment_hash": 3,
"WaitAnyInvoice.payment_preimage": 12,
"WaitAnyInvoice.status": 4
},
"WaitinvoiceRequest": {
"WaitInvoice.label": 1
},
"WaitinvoiceResponse": {
"WaitInvoice.amount_msat": 6,
"WaitInvoice.amount_received_msat": 10,
"WaitInvoice.bolt11": 7,
"WaitInvoice.bolt12": 8,
"WaitInvoice.description": 2,
"WaitInvoice.expires_at": 5,
"WaitInvoice.label": 1,
"WaitInvoice.paid_at": 11,
"WaitInvoice.pay_index": 9,
"WaitInvoice.payment_hash": 3,
"WaitInvoice.payment_preimage": 12,
"WaitInvoice.status": 4
},
"WaitsendpayRequest": {
"WaitSendPay.partid": 2,
"WaitSendPay.payment_hash": 1,
"WaitSendPay.timeout": 3
},
"WaitsendpayResponse": {
"WaitSendPay.amount_msat": 5,
"WaitSendPay.amount_sent_msat": 8,
"WaitSendPay.bolt11": 11,
"WaitSendPay.bolt12": 12,
"WaitSendPay.created_at": 7,
"WaitSendPay.destination": 6,
"WaitSendPay.groupid": 2,
"WaitSendPay.id": 1,
"WaitSendPay.label": 9,
"WaitSendPay.partid": 10,
"WaitSendPay.payment_hash": 3,
"WaitSendPay.payment_preimage": 13,
"WaitSendPay.status": 4
},
"WithdrawRequest": {
"Withdraw.destination": 1,
"Withdraw.minconf": 3,
"Withdraw.satoshi": 2,
"Withdraw.utxos[]": 4
},
"WithdrawResponse": {
"Withdraw.psbt": 3,
"Withdraw.tx": 1,
"Withdraw.txid": 2
}
}
}

View File

@@ -11,6 +11,7 @@ service Node {
rpc Getinfo(GetinfoRequest) returns (GetinfoResponse) {}
rpc ListPeers(ListpeersRequest) returns (ListpeersResponse) {}
rpc ListFunds(ListfundsRequest) returns (ListfundsResponse) {}
rpc SendPay(SendpayRequest) returns (SendpayResponse) {}
rpc ListChannels(ListchannelsRequest) returns (ListchannelsResponse) {}
rpc AddGossip(AddgossipRequest) returns (AddgossipResponse) {}
rpc AutoCleanInvoice(AutocleaninvoiceRequest) returns (AutocleaninvoiceResponse) {}
@@ -19,12 +20,24 @@ service Node {
rpc ConnectPeer(ConnectRequest) returns (ConnectResponse) {}
rpc CreateInvoice(CreateinvoiceRequest) returns (CreateinvoiceResponse) {}
rpc Datastore(DatastoreRequest) returns (DatastoreResponse) {}
rpc CreateOnion(CreateonionRequest) returns (CreateonionResponse) {}
rpc DelDatastore(DeldatastoreRequest) returns (DeldatastoreResponse) {}
rpc DelExpiredInvoice(DelexpiredinvoiceRequest) returns (DelexpiredinvoiceResponse) {}
rpc DelInvoice(DelinvoiceRequest) returns (DelinvoiceResponse) {}
rpc Invoice(InvoiceRequest) returns (InvoiceResponse) {}
rpc ListDatastore(ListdatastoreRequest) returns (ListdatastoreResponse) {}
rpc ListInvoices(ListinvoicesRequest) returns (ListinvoicesResponse) {}
rpc SendOnion(SendonionRequest) returns (SendonionResponse) {}
rpc ListSendPays(ListsendpaysRequest) returns (ListsendpaysResponse) {}
rpc ListTransactions(ListtransactionsRequest) returns (ListtransactionsResponse) {}
rpc Pay(PayRequest) returns (PayResponse) {}
rpc ListNodes(ListnodesRequest) returns (ListnodesResponse) {}
rpc WaitAnyInvoice(WaitanyinvoiceRequest) returns (WaitanyinvoiceResponse) {}
rpc WaitInvoice(WaitinvoiceRequest) returns (WaitinvoiceResponse) {}
rpc WaitSendPay(WaitsendpayRequest) returns (WaitsendpayResponse) {}
rpc NewAddr(NewaddrRequest) returns (NewaddrResponse) {}
rpc Withdraw(WithdrawRequest) returns (WithdrawResponse) {}
rpc KeySend(KeysendRequest) returns (KeysendResponse) {}
}
message GetinfoRequest {
@@ -271,6 +284,45 @@ message ListfundsChannels {
optional string short_channel_id = 8;
}
message SendpayRequest {
repeated SendpayRoute route = 1;
bytes payment_hash = 2;
optional string label = 3;
optional Amount msatoshi = 4;
optional string bolt11 = 5;
optional bytes payment_secret = 6;
optional uint32 partid = 7;
}
message SendpayResponse {
// SendPay.status
enum SendpayStatus {
PENDING = 0;
COMPLETE = 1;
}
uint64 id = 1;
optional uint64 groupid = 2;
bytes payment_hash = 3;
SendpayStatus status = 4;
optional Amount amount_msat = 5;
optional bytes destination = 6;
uint64 created_at = 7;
Amount amount_sent_msat = 8;
optional string label = 9;
optional uint64 partid = 10;
optional string bolt11 = 11;
optional string bolt12 = 12;
optional bytes payment_preimage = 13;
optional string message = 14;
}
message SendpayRoute {
Amount msatoshi = 1;
bytes id = 2;
uint32 delay = 3;
string channel = 4;
}
message ListchannelsRequest {
optional string short_channel_id = 1;
optional bytes source = 2;
@@ -432,6 +484,23 @@ message DatastoreResponse {
optional string string = 4;
}
message CreateonionRequest {
repeated CreateonionHops hops = 1;
bytes assocdata = 2;
optional bytes session_key = 3;
optional uint32 onion_size = 4;
}
message CreateonionResponse {
bytes onion = 1;
repeated bytes shared_secrets = 2;
}
message CreateonionHops {
bytes pubkey = 1;
bytes payload = 2;
}
message DeldatastoreRequest {
repeated string key = 1;
optional uint64 generation = 2;
@@ -550,3 +619,323 @@ message ListinvoicesInvoices {
optional uint64 paid_at = 13;
optional bytes payment_preimage = 14;
}
message SendonionRequest {
bytes onion = 1;
}
message SendonionResponse {
// SendOnion.status
enum SendonionStatus {
PENDING = 0;
COMPLETE = 1;
}
uint64 id = 1;
bytes payment_hash = 2;
SendonionStatus status = 3;
optional Amount amount_msat = 4;
optional bytes destination = 5;
uint64 created_at = 6;
Amount amount_sent_msat = 7;
optional string label = 8;
optional string bolt11 = 9;
optional string bolt12 = 10;
optional bytes payment_preimage = 11;
optional string message = 12;
}
message SendonionFirst_hop {
bytes id = 1;
Amount amount_msat = 2;
uint32 delay = 3;
}
message ListsendpaysRequest {
// ListSendPays.status
enum ListsendpaysStatus {
PENDING = 0;
COMPLETE = 1;
FAILED = 2;
}
optional string bolt11 = 1;
optional bytes payment_hash = 2;
optional ListsendpaysStatus status = 3;
}
message ListsendpaysResponse {
repeated ListsendpaysPayments payments = 1;
}
message ListsendpaysPayments {
// ListSendPays.payments[].status
enum ListsendpaysPaymentsStatus {
PENDING = 0;
FAILED = 1;
COMPLETE = 2;
}
uint64 id = 1;
optional uint64 groupid = 2;
bytes payment_hash = 3;
ListsendpaysPaymentsStatus status = 4;
optional Amount amount_msat = 5;
optional bytes destination = 6;
uint64 created_at = 7;
Amount amount_sent_msat = 8;
optional string label = 9;
optional string bolt11 = 10;
optional string bolt12 = 11;
optional bytes payment_preimage = 12;
optional bytes erroronion = 13;
}
message ListtransactionsRequest {
}
message ListtransactionsResponse {
repeated ListtransactionsTransactions transactions = 1;
}
message ListtransactionsTransactions {
bytes hash = 1;
bytes rawtx = 2;
uint32 blockheight = 3;
uint32 txindex = 4;
optional string channel = 6;
uint32 locktime = 7;
uint32 version = 8;
repeated ListtransactionsTransactionsInputs inputs = 9;
repeated ListtransactionsTransactionsOutputs outputs = 10;
}
message ListtransactionsTransactionsInputs {
// ListTransactions.transactions[].inputs[].type
enum ListtransactionsTransactionsInputsType {
THEIRS = 0;
DEPOSIT = 1;
WITHDRAW = 2;
CHANNEL_FUNDING = 3;
CHANNEL_MUTUAL_CLOSE = 4;
CHANNEL_UNILATERAL_CLOSE = 5;
CHANNEL_SWEEP = 6;
CHANNEL_HTLC_SUCCESS = 7;
CHANNEL_HTLC_TIMEOUT = 8;
CHANNEL_PENALTY = 9;
CHANNEL_UNILATERAL_CHEAT = 10;
}
bytes txid = 1;
uint32 index = 2;
uint32 sequence = 3;
optional ListtransactionsTransactionsInputsType item_type = 4;
optional string channel = 5;
}
message ListtransactionsTransactionsOutputs {
// ListTransactions.transactions[].outputs[].type
enum ListtransactionsTransactionsOutputsType {
THEIRS = 0;
DEPOSIT = 1;
WITHDRAW = 2;
CHANNEL_FUNDING = 3;
CHANNEL_MUTUAL_CLOSE = 4;
CHANNEL_UNILATERAL_CLOSE = 5;
CHANNEL_SWEEP = 6;
CHANNEL_HTLC_SUCCESS = 7;
CHANNEL_HTLC_TIMEOUT = 8;
CHANNEL_PENALTY = 9;
CHANNEL_UNILATERAL_CHEAT = 10;
}
uint32 index = 1;
Amount msat = 2;
bytes scriptPubKey = 3;
optional ListtransactionsTransactionsOutputsType item_type = 4;
optional string channel = 5;
}
message PayRequest {
string bolt11 = 1;
optional Amount msatoshi = 2;
optional string label = 3;
optional float riskfactor = 8;
optional float maxfeepercent = 4;
optional uint32 retry_for = 5;
optional uint32 maxdelay = 6;
optional float exemptfee = 7;
}
message PayResponse {
// Pay.status
enum PayStatus {
COMPLETE = 0;
PENDING = 1;
FAILED = 2;
}
bytes payment_preimage = 1;
optional bytes destination = 2;
bytes payment_hash = 3;
sint64 created_at = 4;
uint32 parts = 5;
Amount amount_msat = 6;
Amount amount_sent_msat = 7;
optional string warning_partial_completion = 8;
PayStatus status = 9;
}
message ListnodesRequest {
optional bytes id = 1;
}
message ListnodesResponse {
repeated ListnodesNodes nodes = 1;
}
message ListnodesNodes {
bytes nodeid = 1;
optional uint32 last_timestamp = 2;
optional string alias = 3;
optional bytes color = 4;
optional bytes features = 5;
repeated ListnodesNodesAddresses addresses = 6;
}
message ListnodesNodesAddresses {
// ListNodes.nodes[].addresses[].type
enum ListnodesNodesAddressesType {
DNS = 0;
IPV4 = 1;
IPV6 = 2;
TORV2 = 3;
TORV3 = 4;
WEBSOCKET = 5;
}
ListnodesNodesAddressesType item_type = 1;
uint32 port = 2;
optional string address = 3;
}
message WaitanyinvoiceRequest {
optional sint64 lastpay_index = 1;
optional sint64 timeout = 2;
}
message WaitanyinvoiceResponse {
// WaitAnyInvoice.status
enum WaitanyinvoiceStatus {
PAID = 0;
EXPIRED = 1;
}
string label = 1;
string description = 2;
bytes payment_hash = 3;
WaitanyinvoiceStatus status = 4;
uint64 expires_at = 5;
optional Amount amount_msat = 6;
optional string bolt11 = 7;
optional string bolt12 = 8;
optional uint64 pay_index = 9;
optional Amount amount_received_msat = 10;
optional uint64 paid_at = 11;
optional bytes payment_preimage = 12;
}
message WaitinvoiceRequest {
string label = 1;
}
message WaitinvoiceResponse {
// WaitInvoice.status
enum WaitinvoiceStatus {
PAID = 0;
EXPIRED = 1;
}
string label = 1;
string description = 2;
bytes payment_hash = 3;
WaitinvoiceStatus status = 4;
uint64 expires_at = 5;
optional Amount amount_msat = 6;
optional string bolt11 = 7;
optional string bolt12 = 8;
optional uint64 pay_index = 9;
optional Amount amount_received_msat = 10;
optional uint64 paid_at = 11;
optional bytes payment_preimage = 12;
}
message WaitsendpayRequest {
bytes payment_hash = 1;
optional uint32 partid = 2;
optional uint32 timeout = 3;
}
message WaitsendpayResponse {
// WaitSendPay.status
enum WaitsendpayStatus {
COMPLETE = 0;
}
uint64 id = 1;
optional uint64 groupid = 2;
bytes payment_hash = 3;
WaitsendpayStatus status = 4;
optional Amount amount_msat = 5;
optional bytes destination = 6;
uint64 created_at = 7;
Amount amount_sent_msat = 8;
optional string label = 9;
optional uint64 partid = 10;
optional string bolt11 = 11;
optional string bolt12 = 12;
optional bytes payment_preimage = 13;
}
message NewaddrRequest {
// NewAddr.addresstype
enum NewaddrAddresstype {
BECH32 = 0;
P2SH_SEGWIT = 1;
}
optional NewaddrAddresstype addresstype = 1;
}
message NewaddrResponse {
optional string bech32 = 1;
optional string p2sh_segwit = 2;
}
message WithdrawRequest {
bytes destination = 1;
optional Amount satoshi = 2;
optional uint32 minconf = 3;
repeated Utxo utxos = 4;
}
message WithdrawResponse {
bytes tx = 1;
bytes txid = 2;
string psbt = 3;
}
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 Amount exemptfee = 7;
}
message KeysendResponse {
// KeySend.status
enum KeysendStatus {
COMPLETE = 0;
}
bytes payment_preimage = 1;
optional bytes destination = 2;
bytes payment_hash = 3;
sint64 created_at = 4;
uint32 parts = 5;
Amount amount_msat = 6;
Amount amount_sent_msat = 7;
optional string warning_partial_completion = 8;
KeysendStatus status = 9;
}

View File

@@ -24,4 +24,9 @@ enum ChannelState {
DualopendAwaitingLockin = 10;
}
message ChannelStateChangeCause {}
message ChannelStateChangeCause {}
message Utxo {
bytes txid = 1;
uint32 outnum = 2;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
tonic::include_proto!("cln");
use cln_rpc::primitives::Amount as JAmount;
use cln_rpc::primitives::{Amount as JAmount, Utxo as JUtxo};
impl From<JAmount> for Amount {
fn from(a: JAmount) -> Self {
@@ -10,6 +10,24 @@ impl From<JAmount> for Amount {
impl From<&Amount> for JAmount {
fn from(a: &Amount) -> Self {
JAmount::from_msat(a.msat)
JAmount::from_msat(a.msat)
}
}
impl From<JUtxo> for Utxo {
fn from(a: JUtxo) -> Self {
Utxo {
txid: a.txid,
outnum: a.outnum,
}
}
}
impl From<&Utxo> for JUtxo {
fn from(a: &Utxo) -> Self {
JUtxo {
txid: a.txid.clone(),
outnum: a.outnum,
}
}
}

View File

@@ -116,6 +116,36 @@ async fn list_funds(
}
async fn send_pay(
&self,
request: tonic::Request<pb::SendpayRequest>,
) -> Result<tonic::Response<pb::SendpayResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::SendpayRequest = (&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::SendPay(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method SendPay: {:?}", e)))?;
match result {
Response::SendPay(r) => Ok(
tonic::Response::new((&r).into())
),
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call SendPay",
r
)
)),
}
}
async fn list_channels(
&self,
request: tonic::Request<pb::ListchannelsRequest>,
@@ -356,6 +386,36 @@ async fn datastore(
}
async fn create_onion(
&self,
request: tonic::Request<pb::CreateonionRequest>,
) -> Result<tonic::Response<pb::CreateonionResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::CreateonionRequest = (&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::CreateOnion(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method CreateOnion: {:?}", e)))?;
match result {
Response::CreateOnion(r) => Ok(
tonic::Response::new((&r).into())
),
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call CreateOnion",
r
)
)),
}
}
async fn del_datastore(
&self,
request: tonic::Request<pb::DeldatastoreRequest>,
@@ -536,4 +596,334 @@ async fn list_invoices(
}
async fn send_onion(
&self,
request: tonic::Request<pb::SendonionRequest>,
) -> Result<tonic::Response<pb::SendonionResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::SendonionRequest = (&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::SendOnion(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method SendOnion: {:?}", e)))?;
match result {
Response::SendOnion(r) => Ok(
tonic::Response::new((&r).into())
),
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call SendOnion",
r
)
)),
}
}
async fn list_send_pays(
&self,
request: tonic::Request<pb::ListsendpaysRequest>,
) -> Result<tonic::Response<pb::ListsendpaysResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::ListsendpaysRequest = (&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::ListSendPays(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method ListSendPays: {:?}", e)))?;
match result {
Response::ListSendPays(r) => Ok(
tonic::Response::new((&r).into())
),
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call ListSendPays",
r
)
)),
}
}
async fn list_transactions(
&self,
request: tonic::Request<pb::ListtransactionsRequest>,
) -> Result<tonic::Response<pb::ListtransactionsResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::ListtransactionsRequest = (&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::ListTransactions(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method ListTransactions: {:?}", e)))?;
match result {
Response::ListTransactions(r) => Ok(
tonic::Response::new((&r).into())
),
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call ListTransactions",
r
)
)),
}
}
async fn pay(
&self,
request: tonic::Request<pb::PayRequest>,
) -> Result<tonic::Response<pb::PayResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::PayRequest = (&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::Pay(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method Pay: {:?}", e)))?;
match result {
Response::Pay(r) => Ok(
tonic::Response::new((&r).into())
),
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call Pay",
r
)
)),
}
}
async fn list_nodes(
&self,
request: tonic::Request<pb::ListnodesRequest>,
) -> Result<tonic::Response<pb::ListnodesResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::ListnodesRequest = (&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::ListNodes(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method ListNodes: {:?}", e)))?;
match result {
Response::ListNodes(r) => Ok(
tonic::Response::new((&r).into())
),
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call ListNodes",
r
)
)),
}
}
async fn wait_any_invoice(
&self,
request: tonic::Request<pb::WaitanyinvoiceRequest>,
) -> Result<tonic::Response<pb::WaitanyinvoiceResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::WaitanyinvoiceRequest = (&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::WaitAnyInvoice(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method WaitAnyInvoice: {:?}", e)))?;
match result {
Response::WaitAnyInvoice(r) => Ok(
tonic::Response::new((&r).into())
),
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call WaitAnyInvoice",
r
)
)),
}
}
async fn wait_invoice(
&self,
request: tonic::Request<pb::WaitinvoiceRequest>,
) -> Result<tonic::Response<pb::WaitinvoiceResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::WaitinvoiceRequest = (&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::WaitInvoice(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method WaitInvoice: {:?}", e)))?;
match result {
Response::WaitInvoice(r) => Ok(
tonic::Response::new((&r).into())
),
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call WaitInvoice",
r
)
)),
}
}
async fn wait_send_pay(
&self,
request: tonic::Request<pb::WaitsendpayRequest>,
) -> Result<tonic::Response<pb::WaitsendpayResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::WaitsendpayRequest = (&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::WaitSendPay(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method WaitSendPay: {:?}", e)))?;
match result {
Response::WaitSendPay(r) => Ok(
tonic::Response::new((&r).into())
),
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call WaitSendPay",
r
)
)),
}
}
async fn new_addr(
&self,
request: tonic::Request<pb::NewaddrRequest>,
) -> Result<tonic::Response<pb::NewaddrResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::NewaddrRequest = (&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::NewAddr(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method NewAddr: {:?}", e)))?;
match result {
Response::NewAddr(r) => Ok(
tonic::Response::new((&r).into())
),
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call NewAddr",
r
)
)),
}
}
async fn withdraw(
&self,
request: tonic::Request<pb::WithdrawRequest>,
) -> Result<tonic::Response<pb::WithdrawResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::WithdrawRequest = (&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::Withdraw(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method Withdraw: {:?}", e)))?;
match result {
Response::Withdraw(r) => Ok(
tonic::Response::new((&r).into())
),
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call Withdraw",
r
)
)),
}
}
async fn key_send(
&self,
request: tonic::Request<pb::KeysendRequest>,
) -> Result<tonic::Response<pb::KeysendResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::KeysendRequest = (&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::KeySend(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method KeySend: {:?}", e)))?;
match result {
Response::KeySend(r) => Ok(
tonic::Response::new((&r).into())
),
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call KeySend",
r
)
)),
}
}
}

View File

@@ -17,6 +17,7 @@ tokio-util = { version = "0.6.9", features = ["codec"] }
tokio = { version = "1", features = ["net"]}
native-tls = { version = "*", features = ["vendored"] }
futures-util = { version = "*", features = [ "sink" ] }
hex = "0.4.3"
[dev-dependencies]
tokio = { version = "1", features = ["net", "macros", "rt-multi-thread"]}

View File

@@ -19,6 +19,7 @@ pub enum Request {
Getinfo(requests::GetinfoRequest),
ListPeers(requests::ListpeersRequest),
ListFunds(requests::ListfundsRequest),
SendPay(requests::SendpayRequest),
ListChannels(requests::ListchannelsRequest),
AddGossip(requests::AddgossipRequest),
AutoCleanInvoice(requests::AutocleaninvoiceRequest),
@@ -27,12 +28,24 @@ pub enum Request {
ConnectPeer(requests::ConnectRequest),
CreateInvoice(requests::CreateinvoiceRequest),
Datastore(requests::DatastoreRequest),
CreateOnion(requests::CreateonionRequest),
DelDatastore(requests::DeldatastoreRequest),
DelExpiredInvoice(requests::DelexpiredinvoiceRequest),
DelInvoice(requests::DelinvoiceRequest),
Invoice(requests::InvoiceRequest),
ListDatastore(requests::ListdatastoreRequest),
ListInvoices(requests::ListinvoicesRequest),
SendOnion(requests::SendonionRequest),
ListSendPays(requests::ListsendpaysRequest),
ListTransactions(requests::ListtransactionsRequest),
Pay(requests::PayRequest),
ListNodes(requests::ListnodesRequest),
WaitAnyInvoice(requests::WaitanyinvoiceRequest),
WaitInvoice(requests::WaitinvoiceRequest),
WaitSendPay(requests::WaitsendpayRequest),
NewAddr(requests::NewaddrRequest),
Withdraw(requests::WithdrawRequest),
KeySend(requests::KeysendRequest),
}
#[derive(Clone, Debug, Serialize, Deserialize)]
@@ -42,6 +55,7 @@ pub enum Response {
Getinfo(responses::GetinfoResponse),
ListPeers(responses::ListpeersResponse),
ListFunds(responses::ListfundsResponse),
SendPay(responses::SendpayResponse),
ListChannels(responses::ListchannelsResponse),
AddGossip(responses::AddgossipResponse),
AutoCleanInvoice(responses::AutocleaninvoiceResponse),
@@ -50,12 +64,24 @@ pub enum Response {
ConnectPeer(responses::ConnectResponse),
CreateInvoice(responses::CreateinvoiceResponse),
Datastore(responses::DatastoreResponse),
CreateOnion(responses::CreateonionResponse),
DelDatastore(responses::DeldatastoreResponse),
DelExpiredInvoice(responses::DelexpiredinvoiceResponse),
DelInvoice(responses::DelinvoiceResponse),
Invoice(responses::InvoiceResponse),
ListDatastore(responses::ListdatastoreResponse),
ListInvoices(responses::ListinvoicesResponse),
SendOnion(responses::SendonionResponse),
ListSendPays(responses::ListsendpaysResponse),
ListTransactions(responses::ListtransactionsResponse),
Pay(responses::PayResponse),
ListNodes(responses::ListnodesResponse),
WaitAnyInvoice(responses::WaitanyinvoiceResponse),
WaitInvoice(responses::WaitinvoiceResponse),
WaitSendPay(responses::WaitsendpayResponse),
NewAddr(responses::NewaddrResponse),
Withdraw(responses::WithdrawResponse),
KeySend(responses::KeysendResponse),
}
pub mod requests {
@@ -82,6 +108,36 @@ pub mod requests {
pub spent: Option<bool>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SendpayRoute {
#[serde(alias = "msatoshi")]
pub msatoshi: Amount,
#[serde(alias = "id")]
pub id: String,
#[serde(alias = "delay")]
pub delay: u16,
#[serde(alias = "channel")]
pub channel: String,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SendpayRequest {
#[serde(alias = "route")]
pub route: Vec<SendpayRoute>,
#[serde(alias = "payment_hash")]
pub payment_hash: String,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")]
pub label: Option<String>,
#[serde(alias = "msatoshi", skip_serializing_if = "Option::is_none")]
pub msatoshi: Option<Amount>,
#[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")]
pub bolt11: Option<String>,
#[serde(alias = "payment_secret", skip_serializing_if = "Option::is_none")]
pub payment_secret: Option<String>,
#[serde(alias = "partid", skip_serializing_if = "Option::is_none")]
pub partid: Option<u16>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListchannelsRequest {
#[serde(alias = "short_channel_id", skip_serializing_if = "Option::is_none")]
@@ -186,6 +242,26 @@ pub mod requests {
pub generation: Option<u64>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CreateonionHops {
#[serde(alias = "pubkey")]
pub pubkey: String,
#[serde(alias = "payload")]
pub payload: String,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CreateonionRequest {
#[serde(alias = "hops")]
pub hops: Vec<CreateonionHops>,
#[serde(alias = "assocdata")]
pub assocdata: String,
#[serde(alias = "session_key", skip_serializing_if = "Option::is_none")]
pub session_key: Option<String>,
#[serde(alias = "onion_size", skip_serializing_if = "Option::is_none")]
pub onion_size: Option<u16>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct DeldatastoreRequest {
#[serde(alias = "key")]
@@ -262,6 +338,156 @@ pub mod requests {
pub offer_id: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SendonionFirst_hop {
#[serde(alias = "id")]
pub id: String,
#[serde(alias = "amount_msat")]
pub amount_msat: Amount,
#[serde(alias = "delay")]
pub delay: u16,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SendonionRequest {
#[serde(alias = "onion")]
pub onion: String,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum ListsendpaysStatus {
PENDING,
COMPLETE,
FAILED,
}
impl TryFrom<i32> for ListsendpaysStatus {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<ListsendpaysStatus, anyhow::Error> {
match c {
0 => Ok(ListsendpaysStatus::PENDING),
1 => Ok(ListsendpaysStatus::COMPLETE),
2 => Ok(ListsendpaysStatus::FAILED),
o => Err(anyhow::anyhow!("Unknown variant {} for enum ListsendpaysStatus", o)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListsendpaysRequest {
#[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")]
pub bolt11: Option<String>,
#[serde(alias = "payment_hash", skip_serializing_if = "Option::is_none")]
pub payment_hash: Option<String>,
pub status: Option<ListsendpaysStatus>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListtransactionsRequest {
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PayRequest {
#[serde(alias = "bolt11")]
pub bolt11: String,
#[serde(alias = "msatoshi", skip_serializing_if = "Option::is_none")]
pub msatoshi: Option<Amount>,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")]
pub label: Option<String>,
#[serde(alias = "riskfactor", skip_serializing_if = "Option::is_none")]
pub riskfactor: Option<f32>,
#[serde(alias = "maxfeepercent", skip_serializing_if = "Option::is_none")]
pub maxfeepercent: Option<f32>,
#[serde(alias = "retry_for", skip_serializing_if = "Option::is_none")]
pub retry_for: Option<u16>,
#[serde(alias = "maxdelay", skip_serializing_if = "Option::is_none")]
pub maxdelay: Option<u16>,
#[serde(alias = "exemptfee", skip_serializing_if = "Option::is_none")]
pub exemptfee: Option<f32>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListnodesRequest {
#[serde(alias = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WaitanyinvoiceRequest {
#[serde(alias = "lastpay_index", skip_serializing_if = "Option::is_none")]
pub lastpay_index: Option<i64>,
#[serde(alias = "timeout", skip_serializing_if = "Option::is_none")]
pub timeout: Option<i64>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WaitinvoiceRequest {
#[serde(alias = "label")]
pub label: String,
}
#[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<u16>,
#[serde(alias = "timeout", skip_serializing_if = "Option::is_none")]
pub timeout: Option<u32>,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum NewaddrAddresstype {
BECH32,
P2SH_SEGWIT,
}
impl TryFrom<i32> for NewaddrAddresstype {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<NewaddrAddresstype, anyhow::Error> {
match c {
0 => Ok(NewaddrAddresstype::BECH32),
1 => Ok(NewaddrAddresstype::P2SH_SEGWIT),
o => Err(anyhow::anyhow!("Unknown variant {} for enum NewaddrAddresstype", o)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct NewaddrRequest {
pub addresstype: Option<NewaddrAddresstype>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WithdrawRequest {
#[serde(alias = "destination")]
pub destination: String,
#[serde(alias = "satoshi", skip_serializing_if = "Option::is_none")]
pub satoshi: Option<Amount>,
#[serde(alias = "minconf", skip_serializing_if = "Option::is_none")]
pub minconf: Option<u16>,
#[serde(alias = "utxos")]
pub utxos: Vec<Utxo>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct KeysendRequest {
#[serde(alias = "destination")]
pub destination: String,
#[serde(alias = "msatoshi")]
pub msatoshi: Amount,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")]
pub label: Option<String>,
#[serde(alias = "maxfeepercent", skip_serializing_if = "Option::is_none")]
pub maxfeepercent: Option<f32>,
#[serde(alias = "retry_for", skip_serializing_if = "Option::is_none")]
pub retry_for: Option<i64>,
#[serde(alias = "maxdelay", skip_serializing_if = "Option::is_none")]
pub maxdelay: Option<i64>,
#[serde(alias = "exemptfee", skip_serializing_if = "Option::is_none")]
pub exemptfee: Option<Amount>,
}
}
@@ -786,6 +1012,57 @@ pub mod responses {
pub channels: Vec<ListfundsChannels>,
}
/// status of the payment (could be complete if already sent previously)
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum SendpayStatus {
PENDING,
COMPLETE,
}
impl TryFrom<i32> for SendpayStatus {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<SendpayStatus, anyhow::Error> {
match c {
0 => Ok(SendpayStatus::PENDING),
1 => Ok(SendpayStatus::COMPLETE),
o => Err(anyhow::anyhow!("Unknown variant {} for enum SendpayStatus", o)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SendpayResponse {
#[serde(alias = "id")]
pub id: u64,
#[serde(alias = "groupid", skip_serializing_if = "Option::is_none")]
pub groupid: Option<u64>,
#[serde(alias = "payment_hash")]
pub payment_hash: String,
// Path `SendPay.status`
#[serde(rename = "status")]
pub status: SendpayStatus,
#[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")]
pub amount_msat: Option<Amount>,
#[serde(alias = "destination", skip_serializing_if = "Option::is_none")]
pub destination: Option<String>,
#[serde(alias = "created_at")]
pub created_at: u64,
#[serde(alias = "amount_sent_msat")]
pub amount_sent_msat: Amount,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")]
pub label: Option<String>,
#[serde(alias = "partid", skip_serializing_if = "Option::is_none")]
pub partid: Option<u64>,
#[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")]
pub bolt11: Option<String>,
#[serde(alias = "bolt12", skip_serializing_if = "Option::is_none")]
pub bolt12: Option<String>,
#[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")]
pub payment_preimage: Option<String>,
#[serde(alias = "message", skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListchannelsChannels {
#[serde(alias = "source")]
@@ -1010,6 +1287,14 @@ pub mod responses {
pub string: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CreateonionResponse {
#[serde(alias = "onion")]
pub onion: String,
#[serde(alias = "shared_secrets")]
pub shared_secrets: Vec<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct DeldatastoreResponse {
#[serde(alias = "key")]
@@ -1170,5 +1455,535 @@ pub mod responses {
pub invoices: Vec<ListinvoicesInvoices>,
}
/// status of the payment (could be complete if already sent previously)
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum SendonionStatus {
PENDING,
COMPLETE,
}
impl TryFrom<i32> for SendonionStatus {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<SendonionStatus, anyhow::Error> {
match c {
0 => Ok(SendonionStatus::PENDING),
1 => Ok(SendonionStatus::COMPLETE),
o => Err(anyhow::anyhow!("Unknown variant {} for enum SendonionStatus", o)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SendonionResponse {
#[serde(alias = "id")]
pub id: u64,
#[serde(alias = "payment_hash")]
pub payment_hash: String,
// Path `SendOnion.status`
#[serde(rename = "status")]
pub status: SendonionStatus,
#[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")]
pub amount_msat: Option<Amount>,
#[serde(alias = "destination", skip_serializing_if = "Option::is_none")]
pub destination: Option<String>,
#[serde(alias = "created_at")]
pub created_at: u64,
#[serde(alias = "amount_sent_msat")]
pub amount_sent_msat: Amount,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")]
pub label: Option<String>,
#[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")]
pub bolt11: Option<String>,
#[serde(alias = "bolt12", skip_serializing_if = "Option::is_none")]
pub bolt12: Option<String>,
#[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")]
pub payment_preimage: Option<String>,
#[serde(alias = "message", skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
}
/// status of the payment
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum ListsendpaysPaymentsStatus {
PENDING,
FAILED,
COMPLETE,
}
impl TryFrom<i32> for ListsendpaysPaymentsStatus {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<ListsendpaysPaymentsStatus, anyhow::Error> {
match c {
0 => Ok(ListsendpaysPaymentsStatus::PENDING),
1 => Ok(ListsendpaysPaymentsStatus::FAILED),
2 => Ok(ListsendpaysPaymentsStatus::COMPLETE),
o => Err(anyhow::anyhow!("Unknown variant {} for enum ListsendpaysPaymentsStatus", o)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListsendpaysPayments {
#[serde(alias = "id")]
pub id: u64,
#[serde(alias = "groupid", skip_serializing_if = "Option::is_none")]
pub groupid: Option<u64>,
#[serde(alias = "payment_hash")]
pub payment_hash: String,
// Path `ListSendPays.payments[].status`
#[serde(rename = "status")]
pub status: ListsendpaysPaymentsStatus,
#[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")]
pub amount_msat: Option<Amount>,
#[serde(alias = "destination", skip_serializing_if = "Option::is_none")]
pub destination: Option<String>,
#[serde(alias = "created_at")]
pub created_at: u64,
#[serde(alias = "amount_sent_msat")]
pub amount_sent_msat: Amount,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")]
pub label: Option<String>,
#[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")]
pub bolt11: Option<String>,
#[serde(alias = "bolt12", skip_serializing_if = "Option::is_none")]
pub bolt12: Option<String>,
#[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")]
pub payment_preimage: Option<String>,
#[serde(alias = "erroronion", skip_serializing_if = "Option::is_none")]
pub erroronion: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListsendpaysResponse {
#[serde(alias = "payments")]
pub payments: Vec<ListsendpaysPayments>,
}
/// the purpose of this input (*EXPERIMENTAL_FEATURES* only)
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum ListtransactionsTransactionsInputsType {
THEIRS,
DEPOSIT,
WITHDRAW,
CHANNEL_FUNDING,
CHANNEL_MUTUAL_CLOSE,
CHANNEL_UNILATERAL_CLOSE,
CHANNEL_SWEEP,
CHANNEL_HTLC_SUCCESS,
CHANNEL_HTLC_TIMEOUT,
CHANNEL_PENALTY,
CHANNEL_UNILATERAL_CHEAT,
}
impl TryFrom<i32> for ListtransactionsTransactionsInputsType {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<ListtransactionsTransactionsInputsType, anyhow::Error> {
match c {
0 => Ok(ListtransactionsTransactionsInputsType::THEIRS),
1 => Ok(ListtransactionsTransactionsInputsType::DEPOSIT),
2 => Ok(ListtransactionsTransactionsInputsType::WITHDRAW),
3 => Ok(ListtransactionsTransactionsInputsType::CHANNEL_FUNDING),
4 => Ok(ListtransactionsTransactionsInputsType::CHANNEL_MUTUAL_CLOSE),
5 => Ok(ListtransactionsTransactionsInputsType::CHANNEL_UNILATERAL_CLOSE),
6 => Ok(ListtransactionsTransactionsInputsType::CHANNEL_SWEEP),
7 => Ok(ListtransactionsTransactionsInputsType::CHANNEL_HTLC_SUCCESS),
8 => Ok(ListtransactionsTransactionsInputsType::CHANNEL_HTLC_TIMEOUT),
9 => Ok(ListtransactionsTransactionsInputsType::CHANNEL_PENALTY),
10 => Ok(ListtransactionsTransactionsInputsType::CHANNEL_UNILATERAL_CHEAT),
o => Err(anyhow::anyhow!("Unknown variant {} for enum ListtransactionsTransactionsInputsType", o)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListtransactionsTransactionsInputs {
#[serde(alias = "txid")]
pub txid: String,
#[serde(alias = "index")]
pub index: u32,
#[serde(alias = "sequence")]
pub sequence: u32,
pub item_type: Option<ListtransactionsTransactionsInputsType>,
#[serde(alias = "channel", skip_serializing_if = "Option::is_none")]
pub channel: Option<String>,
}
/// the purpose of this output (*EXPERIMENTAL_FEATURES* only)
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum ListtransactionsTransactionsOutputsType {
THEIRS,
DEPOSIT,
WITHDRAW,
CHANNEL_FUNDING,
CHANNEL_MUTUAL_CLOSE,
CHANNEL_UNILATERAL_CLOSE,
CHANNEL_SWEEP,
CHANNEL_HTLC_SUCCESS,
CHANNEL_HTLC_TIMEOUT,
CHANNEL_PENALTY,
CHANNEL_UNILATERAL_CHEAT,
}
impl TryFrom<i32> for ListtransactionsTransactionsOutputsType {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<ListtransactionsTransactionsOutputsType, anyhow::Error> {
match c {
0 => Ok(ListtransactionsTransactionsOutputsType::THEIRS),
1 => Ok(ListtransactionsTransactionsOutputsType::DEPOSIT),
2 => Ok(ListtransactionsTransactionsOutputsType::WITHDRAW),
3 => Ok(ListtransactionsTransactionsOutputsType::CHANNEL_FUNDING),
4 => Ok(ListtransactionsTransactionsOutputsType::CHANNEL_MUTUAL_CLOSE),
5 => Ok(ListtransactionsTransactionsOutputsType::CHANNEL_UNILATERAL_CLOSE),
6 => Ok(ListtransactionsTransactionsOutputsType::CHANNEL_SWEEP),
7 => Ok(ListtransactionsTransactionsOutputsType::CHANNEL_HTLC_SUCCESS),
8 => Ok(ListtransactionsTransactionsOutputsType::CHANNEL_HTLC_TIMEOUT),
9 => Ok(ListtransactionsTransactionsOutputsType::CHANNEL_PENALTY),
10 => Ok(ListtransactionsTransactionsOutputsType::CHANNEL_UNILATERAL_CHEAT),
o => Err(anyhow::anyhow!("Unknown variant {} for enum ListtransactionsTransactionsOutputsType", o)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListtransactionsTransactionsOutputs {
#[serde(alias = "index")]
pub index: u32,
#[serde(alias = "msat")]
pub msat: Amount,
#[serde(alias = "scriptPubKey")]
pub script_pub_key: String,
pub item_type: Option<ListtransactionsTransactionsOutputsType>,
#[serde(alias = "channel", skip_serializing_if = "Option::is_none")]
pub channel: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListtransactionsTransactions {
#[serde(alias = "hash")]
pub hash: String,
#[serde(alias = "rawtx")]
pub rawtx: String,
#[serde(alias = "blockheight")]
pub blockheight: u32,
#[serde(alias = "txindex")]
pub txindex: u32,
#[serde(alias = "channel", skip_serializing_if = "Option::is_none")]
pub channel: Option<String>,
#[serde(alias = "locktime")]
pub locktime: u32,
#[serde(alias = "version")]
pub version: u32,
#[serde(alias = "inputs")]
pub inputs: Vec<ListtransactionsTransactionsInputs>,
#[serde(alias = "outputs")]
pub outputs: Vec<ListtransactionsTransactionsOutputs>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListtransactionsResponse {
#[serde(alias = "transactions")]
pub transactions: Vec<ListtransactionsTransactions>,
}
/// status of payment
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum PayStatus {
COMPLETE,
PENDING,
FAILED,
}
impl TryFrom<i32> for PayStatus {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<PayStatus, anyhow::Error> {
match c {
0 => Ok(PayStatus::COMPLETE),
1 => Ok(PayStatus::PENDING),
2 => Ok(PayStatus::FAILED),
o => Err(anyhow::anyhow!("Unknown variant {} for enum PayStatus", o)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PayResponse {
#[serde(alias = "payment_preimage")]
pub payment_preimage: String,
#[serde(alias = "destination", skip_serializing_if = "Option::is_none")]
pub destination: Option<String>,
#[serde(alias = "payment_hash")]
pub payment_hash: String,
#[serde(alias = "created_at")]
pub created_at: i64,
#[serde(alias = "parts")]
pub parts: u32,
#[serde(alias = "amount_msat")]
pub amount_msat: Amount,
#[serde(alias = "amount_sent_msat")]
pub amount_sent_msat: Amount,
#[serde(alias = "warning_partial_completion", skip_serializing_if = "Option::is_none")]
pub warning_partial_completion: Option<String>,
// Path `Pay.status`
#[serde(rename = "status")]
pub status: PayStatus,
}
/// Type of connection
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum ListnodesNodesAddressesType {
DNS,
IPV4,
IPV6,
TORV2,
TORV3,
WEBSOCKET,
}
impl TryFrom<i32> for ListnodesNodesAddressesType {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<ListnodesNodesAddressesType, anyhow::Error> {
match c {
0 => Ok(ListnodesNodesAddressesType::DNS),
1 => Ok(ListnodesNodesAddressesType::IPV4),
2 => Ok(ListnodesNodesAddressesType::IPV6),
3 => Ok(ListnodesNodesAddressesType::TORV2),
4 => Ok(ListnodesNodesAddressesType::TORV3),
5 => Ok(ListnodesNodesAddressesType::WEBSOCKET),
o => Err(anyhow::anyhow!("Unknown variant {} for enum ListnodesNodesAddressesType", o)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListnodesNodesAddresses {
// Path `ListNodes.nodes[].addresses[].type`
#[serde(rename = "type")]
pub item_type: ListnodesNodesAddressesType,
#[serde(alias = "port")]
pub port: u16,
#[serde(alias = "address", skip_serializing_if = "Option::is_none")]
pub address: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListnodesNodes {
#[serde(alias = "nodeid")]
pub nodeid: String,
#[serde(alias = "last_timestamp", skip_serializing_if = "Option::is_none")]
pub last_timestamp: Option<u32>,
#[serde(alias = "alias", skip_serializing_if = "Option::is_none")]
pub alias: Option<String>,
#[serde(alias = "color", skip_serializing_if = "Option::is_none")]
pub color: Option<String>,
#[serde(alias = "features", skip_serializing_if = "Option::is_none")]
pub features: Option<String>,
#[serde(alias = "addresses")]
pub addresses: Vec<ListnodesNodesAddresses>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListnodesResponse {
#[serde(alias = "nodes")]
pub nodes: Vec<ListnodesNodes>,
}
/// Whether it's paid or expired
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum WaitanyinvoiceStatus {
PAID,
EXPIRED,
}
impl TryFrom<i32> for WaitanyinvoiceStatus {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<WaitanyinvoiceStatus, anyhow::Error> {
match c {
0 => Ok(WaitanyinvoiceStatus::PAID),
1 => Ok(WaitanyinvoiceStatus::EXPIRED),
o => Err(anyhow::anyhow!("Unknown variant {} for enum WaitanyinvoiceStatus", o)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WaitanyinvoiceResponse {
#[serde(alias = "label")]
pub label: String,
#[serde(alias = "description")]
pub description: String,
#[serde(alias = "payment_hash")]
pub payment_hash: String,
// Path `WaitAnyInvoice.status`
#[serde(rename = "status")]
pub status: WaitanyinvoiceStatus,
#[serde(alias = "expires_at")]
pub expires_at: u64,
#[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")]
pub amount_msat: Option<Amount>,
#[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")]
pub bolt11: Option<String>,
#[serde(alias = "bolt12", skip_serializing_if = "Option::is_none")]
pub bolt12: Option<String>,
#[serde(alias = "pay_index", skip_serializing_if = "Option::is_none")]
pub pay_index: Option<u64>,
#[serde(alias = "amount_received_msat", skip_serializing_if = "Option::is_none")]
pub amount_received_msat: Option<Amount>,
#[serde(alias = "paid_at", skip_serializing_if = "Option::is_none")]
pub paid_at: Option<u64>,
#[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")]
pub payment_preimage: Option<String>,
}
/// Whether it's paid or expired
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum WaitinvoiceStatus {
PAID,
EXPIRED,
}
impl TryFrom<i32> for WaitinvoiceStatus {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<WaitinvoiceStatus, anyhow::Error> {
match c {
0 => Ok(WaitinvoiceStatus::PAID),
1 => Ok(WaitinvoiceStatus::EXPIRED),
o => Err(anyhow::anyhow!("Unknown variant {} for enum WaitinvoiceStatus", o)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WaitinvoiceResponse {
#[serde(alias = "label")]
pub label: String,
#[serde(alias = "description")]
pub description: String,
#[serde(alias = "payment_hash")]
pub payment_hash: String,
// Path `WaitInvoice.status`
#[serde(rename = "status")]
pub status: WaitinvoiceStatus,
#[serde(alias = "expires_at")]
pub expires_at: u64,
#[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")]
pub amount_msat: Option<Amount>,
#[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")]
pub bolt11: Option<String>,
#[serde(alias = "bolt12", skip_serializing_if = "Option::is_none")]
pub bolt12: Option<String>,
#[serde(alias = "pay_index", skip_serializing_if = "Option::is_none")]
pub pay_index: Option<u64>,
#[serde(alias = "amount_received_msat", skip_serializing_if = "Option::is_none")]
pub amount_received_msat: Option<Amount>,
#[serde(alias = "paid_at", skip_serializing_if = "Option::is_none")]
pub paid_at: Option<u64>,
#[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")]
pub payment_preimage: Option<String>,
}
/// status of the payment
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum WaitsendpayStatus {
COMPLETE,
}
impl TryFrom<i32> for WaitsendpayStatus {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<WaitsendpayStatus, anyhow::Error> {
match c {
0 => Ok(WaitsendpayStatus::COMPLETE),
o => Err(anyhow::anyhow!("Unknown variant {} for enum WaitsendpayStatus", o)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WaitsendpayResponse {
#[serde(alias = "id")]
pub id: u64,
#[serde(alias = "groupid", skip_serializing_if = "Option::is_none")]
pub groupid: Option<u64>,
#[serde(alias = "payment_hash")]
pub payment_hash: String,
// Path `WaitSendPay.status`
#[serde(rename = "status")]
pub status: WaitsendpayStatus,
#[serde(alias = "amount_msat", skip_serializing_if = "Option::is_none")]
pub amount_msat: Option<Amount>,
#[serde(alias = "destination", skip_serializing_if = "Option::is_none")]
pub destination: Option<String>,
#[serde(alias = "created_at")]
pub created_at: u64,
#[serde(alias = "amount_sent_msat")]
pub amount_sent_msat: Amount,
#[serde(alias = "label", skip_serializing_if = "Option::is_none")]
pub label: Option<String>,
#[serde(alias = "partid", skip_serializing_if = "Option::is_none")]
pub partid: Option<u64>,
#[serde(alias = "bolt11", skip_serializing_if = "Option::is_none")]
pub bolt11: Option<String>,
#[serde(alias = "bolt12", skip_serializing_if = "Option::is_none")]
pub bolt12: Option<String>,
#[serde(alias = "payment_preimage", skip_serializing_if = "Option::is_none")]
pub payment_preimage: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct NewaddrResponse {
#[serde(alias = "bech32", skip_serializing_if = "Option::is_none")]
pub bech32: Option<String>,
#[serde(alias = "p2sh-segwit", skip_serializing_if = "Option::is_none")]
pub p2sh_segwit: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WithdrawResponse {
#[serde(alias = "tx")]
pub tx: String,
#[serde(alias = "txid")]
pub txid: String,
#[serde(alias = "psbt")]
pub psbt: String,
}
/// status of payment
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum KeysendStatus {
COMPLETE,
}
impl TryFrom<i32> for KeysendStatus {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<KeysendStatus, anyhow::Error> {
match c {
0 => Ok(KeysendStatus::COMPLETE),
o => Err(anyhow::anyhow!("Unknown variant {} for enum KeysendStatus", o)),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct KeysendResponse {
#[serde(alias = "payment_preimage")]
pub payment_preimage: String,
#[serde(alias = "destination", skip_serializing_if = "Option::is_none")]
pub destination: Option<String>,
#[serde(alias = "payment_hash")]
pub payment_hash: String,
#[serde(alias = "created_at")]
pub created_at: i64,
#[serde(alias = "parts")]
pub parts: u32,
#[serde(alias = "amount_msat")]
pub amount_msat: Amount,
#[serde(alias = "amount_sent_msat")]
pub amount_sent_msat: Amount,
#[serde(alias = "warning_partial_completion", skip_serializing_if = "Option::is_none")]
pub warning_partial_completion: Option<String>,
// Path `KeySend.status`
#[serde(rename = "status")]
pub status: KeysendStatus,
}
}

View File

@@ -68,6 +68,44 @@ impl Amount {
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct Utxo {
pub txid: Vec<u8>,
pub outnum: u32,
}
impl Serialize for Utxo {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(&format!("{}:{}", hex::encode(&self.txid), self.outnum))
}
}
impl<'de> Deserialize<'de> for Utxo {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
use serde::de::Error;
let s: String = Deserialize::deserialize(deserializer)?;
let splits: Vec<&str> = s.split(':').collect();
if splits.len() != 2 {
return Err(Error::custom("not a valid txid:output tuple"));
}
let txid =
hex::decode(splits[0]).map_err(|_| Error::custom("not a valid hex encoded txid"))?;
let outnum: u32 = splits[1]
.parse()
.map_err(|e| Error::custom(format!("{} is not a valid number: {}", s, e)))?;
Ok(Utxo { txid, outnum })
}
}
#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq)]
pub enum ChannelSide {
LOCAL,

View File

@@ -43,22 +43,35 @@ def load_jsonrpc_service():
"Getinfo",
"ListPeers",
"ListFunds",
# "ListConfigs",
"SendPay",
"ListChannels",
"AddGossip",
"AutoCleanInvoice",
"CheckMessage",
# "check", # No point in mapping this one
"Close",
"Connect",
"CreateInvoice",
# "createonion",
"Datastore",
# "decodepay",
# "decode",
"CreateOnion",
"DelDatastore",
"DelExpiredInvoice",
"DelInvoice",
"Invoice",
"ListDatastore",
"ListInvoices",
"SendOnion",
"ListSendPays",
"ListTransactions",
"Pay",
"ListNodes",
"WaitAnyInvoice",
"WaitInvoice",
"WaitSendPay",
"NewAddr",
"Withdraw",
"KeySend",
# "decodepay",
# "decode",
# "delpay",
# "disableoffer",
# "disconnect",
@@ -70,28 +83,15 @@ def load_jsonrpc_service():
# "fundchannel_start",
# "funderupdate",
# "fundpsbt",
# "getinfo",
# "getlog",
# "getroute",
# "getsharedsecret",
# "help",
"Invoice",
# "keysend",
# "listchannels",
# "listconfigs",
"ListDatastore",
# "listforwards",
# "listfunds",
"ListInvoices",
# "listnodes",
# "listoffers",
# "listpays",
# "listsendpays",
# "listtransactions",
# "multifundchannel",
# "multiwithdraw",
# "newaddr",
# "notifications",
# "offerout",
# "offer",
# "openchannel_abort",
@@ -100,30 +100,27 @@ def load_jsonrpc_service():
# "openchannel_signed",
# "openchannel_update",
# "parsefeerate",
# "pay",
# "ping",
# "plugin",
# "reserveinputs",
# "sendcustommsg",
# "sendinvoice",
# "sendonionmessage",
# "sendonion",
# "sendpay",
# "sendpsbt",
# "setchannelfee",
# "signmessage",
# "signpsbt",
# "stop",
# "txdiscard",
# "txprepare",
# "txsend",
# "unreserveinputs",
# "utxopsbt",
# "waitanyinvoice",
# "waitblockheight",
# "waitinvoice",
# "waitsendpay",
# "withdraw",
# "ListConfigs",
# "check", # No point in mapping this one
# "Stop", # Breaks a core assumption (root is an object) can't map unless we change this
# "UtxoPsbt", # Breaks since the utxos array has dynamic keys which we can't map as is
# "notifications", # No point in mapping this
# "help",
]
methods = [load_jsonrpc_method(name) for name in method_names]
service = Service(name="Node", methods=methods)

View File

@@ -20,7 +20,9 @@ typemap = {
'u32': 'uint32',
'u64': 'uint64',
'u16': 'uint32', # Yeah, I know...
'f32': 'float',
'integer': 'sint64',
"utxo": "Utxo",
}
@@ -33,6 +35,7 @@ overrides = {
'ListPeers.peers[].channels[].closer': "ChannelSide",
'ListPeers.peers[].channels[].features[]': "string",
'ListFunds.channels[].state': 'ChannelState',
'ListTransactions.transactions[].type[]': None,
}
method_name_overrides = {
@@ -258,6 +261,7 @@ class GrpcConverterGenerator:
continue
name = f.normalized()
name = re.sub(r'(?<!^)(?=[A-Z])', '_', name).lower()
if isinstance(f, ArrayField):
typ = f.itemtype.typename
# The inner conversion applied to each element in the
@@ -296,7 +300,8 @@ class GrpcConverterGenerator:
typ,
f'c.{name}.clone()' # default to just assignment
)
self.write(f"{name}: {rhs},\n", numindent=3)
self.write(f"{name}: {rhs}, // Rule #2 for type {typ}\n", numindent=3)
self.write(f"""\
}}
@@ -387,12 +392,13 @@ class GrpcUnconverterGenerator(GrpcConverterGenerator):
'txid?': f'c.{name}.clone().map(|v| hex::encode(v))',
'pubkey': f'hex::encode(&c.{name})',
'pubkey?': f'c.{name}.clone().map(|v| hex::encode(v))',
'msat': f'c.{name}.as_ref().unwrap().into()'
'msat': f'c.{name}.as_ref().unwrap().into()',
'msat?': f'c.{name}.as_ref().map(|a| a.into())',
}.get(
typ,
f'c.{name}.clone()' # default to just assignment
)
self.write(f"{name}: {rhs},\n", numindent=3)
self.write(f"{name}: {rhs}, // Rule #1 for type {typ}\n", numindent=3)
self.write(f"""\
}}

View File

@@ -218,6 +218,8 @@ class PrimitiveField(Field):
"u32",
"u64",
"u8",
"f32",
"float",
"string",
"pubkey",
"signature",
@@ -228,6 +230,7 @@ class PrimitiveField(Field):
"integer",
"u16",
"number",
"utxo", # A string representing the tuple (txid, outnum)
]
def __init__(self, typename, path, description):

View File

@@ -3,6 +3,7 @@ from typing import Tuple
from textwrap import dedent, indent
import logging
import sys
import re
from .model import (ArrayField, CompositeField, EnumField,
PrimitiveField, Service)
@@ -23,6 +24,7 @@ overrides = {
'ListPeers.peers[].channels[].closer': "ChannelSide",
'ListPeers.peers[].channels[].features[]': "string",
'ListFunds.channels[].state': 'ChannelState',
'ListTransactions.transactions[].type[]': None,
}
# A map of schema type to rust primitive types.
@@ -36,6 +38,8 @@ typemap = {
'signature': 'String',
'string': 'String',
'txid': 'String',
'float': 'f32',
'utxo': 'Utxo',
}
header = f"""#![allow(non_camel_case_types)]
@@ -56,6 +60,7 @@ def normalize_varname(field):
"""
# Dashes are not valid names
field.path = field.path.replace("-", "_")
field.path = re.sub(r'(?<!^)(?=[A-Z])', '_', field.path).lower()
return field
@@ -138,7 +143,6 @@ def gen_primitive(p):
def gen_array(a):
name = a.name.normalized().replace("[]", "")
logger.debug(f"Generating array field {a.name} -> {name} ({a.path})")
_, decl = gen_field(a.itemtype)
if isinstance(a.itemtype, PrimitiveField):
@@ -152,6 +156,9 @@ def gen_array(a):
decl = "" # No declaration if we have an override
itemtype = overrides[a.path]
if itemtype is None:
return ("", "") # Override said not to include
itemtype = typemap.get(itemtype, itemtype)
alias = a.name.normalized()[:-2] # Strip the `[]` suffix for arrays.
defi = f" #[serde(alias = \"{alias}\")]\n pub {name}: {'Vec<'*a.dims}{itemtype}{'>'*a.dims},\n"

View File

@@ -84,7 +84,7 @@ On success, an object is returned, containing:
- **parts** (u32): how many attempts this took
- **amount_msat** (msat): Amount the recipient received
- **amount_sent_msat** (msat): Total amount we sent (including fees)
- **status** (string): status of payment (always "complete")
- **status** (string): status of payment (one of "complete", "pending", "failed")
- **destination** (pubkey, optional): the final destination of the payment
The following warnings may also be returned:
@@ -149,4 +149,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:bf507985544575c4ef2fe194fda6a693378cb8ab3bfb30ca7a7c066be271be29)
[comment]: # ( SHA256STAMP:e537b9c74918559db99e673fac63cfa43a347ab80c32f33012ab3655b9edc45e)

View File

@@ -0,0 +1,40 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [
"hops",
"assocdata"
],
"properties": {
"hops": {
"type": "array",
"description": "",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"pubkey",
"payload"
],
"properties": {
"pubkey": {
"type": "pubkey"
},
"payload": {
"type": "hex"
}
}
}
},
"assocdata": {
"type": "hex",
"description": ""
},
"session_key": {
"type": "hex"
},
"onion_size": {
"type": "u16"
}
}
}

View File

@@ -0,0 +1,31 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [
"destination",
"msatoshi"
],
"properties": {
"destination": {
"type": "pubkey"
},
"msatoshi": {
"type": "msat"
},
"label": {
"type": "string"
},
"maxfeepercent": {
"type": "float"
},
"retry_for": {
"type": "number"
},
"maxdelay": {
"type": "number"
},
"exemptfee": {
"type": "msat"
}
}
}

View File

@@ -0,0 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [],
"properties": {
"id": {
"type": "pubkey"
}
}
}

View File

@@ -0,0 +1,21 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [],
"properties": {
"bolt11": {
"type": "string"
},
"payment_hash": {
"type": "hex"
},
"status": {
"type": "string",
"enum": [
"pending",
"complete",
"failed"
]
}
}
}

View File

@@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [],
"additionalProperties": false,
"properties": {}
}

View File

@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [],
"properties": {
"addresstype": {
"type": "string",
"enum": [
"bech32",
"p2sh-segwit"
]
}
}
}

View File

@@ -0,0 +1,33 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [
"bolt11"
],
"properties": {
"bolt11": {
"type": "string"
},
"msatoshi": {
"type": "msat"
},
"label": {
"type": "string"
},
"riskfactor": {
"type": "float"
},
"maxfeepercent": {
"type": "f32"
},
"retry_for": {
"type": "u16"
},
"maxdelay": {
"type": "u16"
},
"exemptfee": {
"type": "f32"
}
}
}

View File

@@ -57,7 +57,9 @@
"status": {
"type": "string",
"enum": [
"complete"
"complete",
"pending",
"failed"
],
"description": "status of payment"
}

View File

@@ -0,0 +1,57 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [
"onion",
"first_hop",
"payment_hash"
],
"properties": {
"onion": {
"type": "hex"
},
"first_hop": {
"type": "object",
"required": [
"id",
"amount_msat",
"delay"
],
"properties": {
"id": {
"type": "pubkey"
},
"amount_msat": {
"type": "msat"
},
"delay": {
"type": "u16"
}
},
"payment_hash": {
"type": "hex"
},
"label": {
"type": "string"
},
"shared_secrets": {
"type": "array",
"itemtype": {
"type": "hex"
}
},
"partid": {
"type": "u16"
},
"bolt11": {
"type": "string"
},
"msatoshi": {
"type": "msat"
},
"destination": {
"type": "pubkey"
}
}
}
}

View File

@@ -0,0 +1,54 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [
"route",
"payment_hash"
],
"properties": {
"route": {
"type": "array",
"items": {
"type": "object",
"required": [
"msatoshi",
"id",
"delay",
"channel"
],
"properties": {
"msatoshi": {
"type": "msat"
},
"id": {
"type": "pubkey"
},
"delay": {
"type": "u16"
},
"channel": {
"type": "short_channel_id"
}
}
}
},
"payment_hash": {
"type": "hex"
},
"label": {
"type": "string"
},
"msatoshi": {
"type": "msat"
},
"bolt11": {
"type": "string"
},
"payment_secret": {
"type": "hex"
},
"partid": {
"type": "u16"
}
}
}

View File

@@ -0,0 +1,13 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [],
"properties": {
"lastpay_index": {
"type": "number"
},
"timeout": {
"type": "number"
}
}
}

View File

@@ -0,0 +1,12 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [
"label"
],
"properties": {
"label": {
"type": "string"
}
}
}

View File

@@ -0,0 +1,18 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [
"payment_hash"
],
"properties": {
"payment_hash": {
"type": "hex"
},
"partid": {
"type": "u16"
},
"timeout": {
"type": "u32"
}
}
}

View File

@@ -0,0 +1,27 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [
"destination"
],
"properties": {
"destination": {
"type": "pubkey"
},
"satoshi": {
"type": "msat"
},
"feerate": {
"type": "feerate"
},
"minconf": {
"type": "u16"
},
"utxos": {
"type": "array",
"items": {
"type": "utxo"
}
}
}
}