mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-09 08:04:45 +00:00
Extends NIP-BC onchain zaps to honor a note's NIP-57 zap-split tags: one Bitcoin transaction pays every pubkey-based recipient atomically, and one kind:8333 receipt is published per recipient (each receipt carries the recipient's pubkey + sat share and shares the same i:<txid>). quartz / OnchainZapBuilder - new buildSplit(recipients = listOf(pubkey to sats), ...) produces a PSBT with one output per recipient + optional change output - existing build(...) now delegates to buildSplit; coin selection and change-vs-dust logic are unchanged for the single-recipient path commons / new OnchainZapSplitter - distribute(totalSats, splits, dustThreshold) does the weighted integer-math allocation, dropping the rounding remainder onto the largest-weight recipient first so the per-recipient sats sum exactly to totalSats - throws DustRecipientException if any share lands below dust; the caller surfaces that as a build-stage failure before the tx is built - unit tests cover equal weights, fractional weights, remainder distribution, dust rejection, and input-order preservation commons / OnchainZapSender.sendSplit - mirrors send() but takes the precomputed shares, builds via buildSplit, and publishes N receipts using the same txid; if one receipt publish fails the broadcast txid + already-published receipt ids are surfaced in the Failure result amethyst / Account.sendOnchainZapWithSplits - thin wrapper that hands off to OnchainZapSender.sendSplit using the signer's pubkey amethyst / OnchainZapSendDialog - detects pubkey-based zap splits on the zappedEvent and, when present, defaults to split mode: a SplitsRecipientSection renders one row per recipient with weight % and live per-recipient sats preview - lnAddress-only splits are filtered out (no pubkey -> no Taproot address); a short note tells the user how many recipients were skipped - the send button label switches to "Send X sats, N ways"; an opt-out button lets the user fall back to single-recipient mode - on send: shares are recomputed via OnchainZapSplitter; below-dust configurations surface as a BUILDING-stage failure before signing