Open Kixunil opened 2 years ago
I can do a PR with some examples, but I need to figure it out some things like this one, I want to create an invoice
pub async fn add_invoice(client: &mut tonic_lnd::Client) -> Result<AddInvoiceResponse, tonic_lnd::Error> {
let invoice = tonic_lnd::rpc::Invoice {
memo: "test invoice".to_string(),
value: 999,
expiry: 3600,
};
let invoice = client
.add_invoice(invoice)
.await?
.into_inner();
Ok(invoice)
}
But I get this error
error[E0063]: missing fields `add_index`, `amp_invoice_state`, `amt_paid` and 21 other fields in initializer of `tonic_lnd::rpc::Invoice`
--> src/lightning.rs:32:19
|
32 | let invoice = tonic_lnd::rpc::Invoice {
| ^^^^^^^^^^^^^^^^^^^^^^^ missing `add_index`, `amp_invoice_state`, `amt_paid` and 21 other fields
I know this fields are in the proto, every I want lnd calculate the preimage, hash and all that stuff like when I run lncli addinvoice
, how can I do this?
Yeah, this is one thing I dislike about prost
(the crate that generates part of the tonic
code) that it's not using builders. It also causes compatibility problems. :( See also https://github.com/tokio-rs/prost/issues/399
I think adding ..Default::default()
at the end of the struct should help but not sure. If not you will have to fill up the fields. :(
It works perfect with ..Default::default()
thank you
This should avoid people being confused like in #7