feat: allow setting custom preimage in spontaneous-send#233
Conversation
|
👋 Thanks for assigning @benthecarman as a reviewer! |
| bolt11_invoice_description, Bolt11InvoiceDescription, | ||
| }; | ||
|
|
||
| use ldk_server_grpc::types::payment_kind; |
There was a problem hiding this comment.
nit: can we have a new line between the imports and const
There was a problem hiding this comment.
@f3r10 Looks like you missed this in your latest push.
| help = "Custom TLV record to attach, format: <type_num>:<hex_value>. Repeatable. type_num must be >= 65536." | ||
| )] | ||
| custom_tlvs: Vec<(u64, Vec<u8>)>, | ||
| #[arg(long)] |
There was a problem hiding this comment.
please add help text
1eba0c8 to
590ea22
Compare
Anyitechs
left a comment
There was a problem hiding this comment.
Thanks!
The CI is currently failing because the proto files are now out of date and needs to be updated.
| }) | ||
| .transpose()?; | ||
|
|
||
| let custom_tlvs: Vec<_> = request.custom_tlvs.iter().map(proto_to_node_custom_tlv).collect(); |
There was a problem hiding this comment.
No strong opinion here, especially as I believe there's really no runtime cost in iterating and mapping over an empty vector. But since we're creating the vector and immediately checking if it's empty in the match statement below.
I'm wondering if we could do something like this instead?
let custom_tlvs: Option<Vec<CustomTlvRecord>> = if request.custom_tlvs.is_empty() {
None
} else {
Some(request.custom_tlvs.iter().map(proto_to_node_custom_tlv).collect())
};
let payment_id = match (preimage, custom_tlvs) {
(None, None) => context.node.spontaneous_payment().send(
request.amount_msat,
node_id,
route_parameters,
)?,
(None, Some(custom_tlvs)) => context.node.spontaneous_payment().send_with_custom_tlvs(
request.amount_msat,
node_id,
route_parameters,
custom_tlvs,
)?,
(Some(preimage), None) => context.node.spontaneous_payment().send_with_preimage(
request.amount_msat,
node_id,
preimage,
route_parameters,
)?,
(Some(preimage), Some(custom_tlvs)) => context
.node
.spontaneous_payment()
.send_with_preimage_and_custom_tlvs(
request.amount_msat,
node_id,
custom_tlvs,
preimage,
route_parameters,
)?,
};
| bolt11_invoice_description, Bolt11InvoiceDescription, | ||
| }; | ||
|
|
||
| use ldk_server_grpc::types::payment_kind; |
There was a problem hiding this comment.
@f3r10 Looks like you missed this in your latest push.
address #226
Summary
preimagefield toSpontaneousSendRequest, allowing callers to supply a custom 32-byte hex preimage instead of having the node generate one randomlysend_with_preimageorsend_with_preimage_and_custom_tlvs) based on whether preimage and/or custom TLVs are present--preimage) and MCP schemaSHA256 of the provided preimage