feat(sdk): sign/encode/decode/verify invoice, receipt and tip frames #77
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_cd793d2c"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The SDK could already send a payment (
sendInvoice/sendTip), but it could not build or inspect a payment frame:pay::sign_*take the ed25519 identity secret andNodeexposed onlyidentity_pk(), so the signing half was unreachable from Kotlin.This adds the signing surface to the node rather than exporting the key, then wraps it for Kotlin.
Core (
src/node.rs)Node::sign_invoice,Node::sign_receipt,Node::sign_tipsign with the node's own identity key and return the core frame struct. No method hands the secret out, and nothing crosses the FFI boundary except the signature.pay_invoiceandtipnow call these instead of signing inline, so there is one signing path rather than two. Behaviour is unchanged: same key, sameunix_now()timestamp, same frames.SDK (
crates/onionwire-sdk/src/lib.rs)Backward compatible; nothing existing changed.
Invoice,Receipt,Tipmirroringsrc/pay.rs.sigis the raw 64-byte signature, not hex, so a frame re-encodes byte-for-byte.Wire::sign_invoice/sign_receipt/sign_tip- async,WireError.Stoppedafter shutdown.encode_invoice/encode_receipt/encode_tip,decode_invoice/decode_receipt/decode_tip(Nonefor a foreign or truncated frame),verify_invoice/verify_receipt/verify_tipagainst the sender's pubkey hex (falsefor a bad key or an edited frame, never a panic).Verification (this branch)
cargo test --lockedincrates/onionwire-sdk- 27 passed, 0 failed (19 before; 8 new).cargo clippy --locked --all-targets -- -D warningsclean.cargo clippy --locked --all-targets -- -D warningsclean;cargo test --locked --lib14 passed;cargo test --locked --test pay11 passed.uniffi-bindgen generate --library libonionwire_sdk.so --language kotlin); the new signatures are on card t_cd793d2c.No wire-format change. Note the card's child tasks
t_2eb62e1e/t_a9a28f76duplicate already-merged PRs #65 / #66 and should be re-checked before apk-dev is dispatched onto them.The SDK could already send an invoice or a tip through Node::pay_invoice / Node::tip, but it could not touch the payment frames themselves: pay::sign_* take the ed25519 identity secret and Node exposed only identity_pk(), so the signing half lived nowhere the SDK could reach. Add the signing surface to the node instead of exporting the key: * Node::sign_invoice / sign_receipt / sign_tip sign with the node's own identity key and return the core frame struct. The secret never leaves the process and there is no API that hands it out. * pay_invoice and tip now call those methods rather than signing inline, so there is one signing path, not two. SDK (crates/onionwire-sdk), all backward compatible: * Records Invoice, Receipt, Tip mirroring src/pay.rs, sig as raw bytes so a frame re-encodes byte-for-byte. * Wire::sign_invoice / sign_receipt / sign_tip (async, over the node). * Free functions encode_invoice / encode_receipt / encode_tip, decode_invoice / decode_receipt / decode_tip (None on a foreign or truncated frame), verify_invoice / verify_receipt / verify_tip against the sender's pubkey hex (false on a bad key, never a panic). Tests: 8 new SDK unit tests (record round-trips through the core encoders, signer-key-only verification, tamper rejection, foreign/truncated frame, typed Stopped error after shutdown). SDK 27 passed, 0 failed; SDK clippy --all-targets -D warnings clean; root clippy --all-targets -D warnings clean; root lib tests 14 passed; tests/pay.rs 11 passed.