@@ -554,218 +554,4 @@ export * from "./tx.js";
554554
555555export * from "./devices.js" ;
556556
557- /**
558- * Unsigned Bitcoin transaction. Parallel to `UnsignedTronTx` /
559- * `UnsignedSolanaTx`. Stores a PSBT (Partially Signed Bitcoin
560- * Transaction, BIP-174) — the device signs it via
561- * `@ledgerhq/hw-app-btc`'s `signPsbtBuffer`, we finalize, extract the
562- * tx hex, and broadcast via the indexer.
563- *
564- * `decoded.outputs[]` and `decoded.changeOutput` carry the human-
565- * readable preview the agent surfaces to the user. The PSBT bytes are
566- * the source of truth — the device walks every output (including
567- * change, with the "change" label when the path matches the wallet's
568- * internal chain) and shows fee + total before asking for approval.
569- */
570- export interface UnsignedBitcoinTx {
571- chain : "bitcoin" ;
572- /**
573- * Discriminator for the action.
574- * - `native_send` — Phase 1 single-output send (also used by issue
575- * #264 multi-source consolidation).
576- * - `rbf_bump` — BIP-125 fee replacement of a stuck mempool tx.
577- * Same input set as the original, recipients preserved verbatim,
578- * the bump is absorbed by the change output.
579- */
580- action : "native_send" | "rbf_bump" ;
581- /**
582- * RBF replacement context — populated only on `action === "rbf_bump"`.
583- * Lets the verification block surface "replacing TX <txid>" and the
584- * old → new fee/fee-rate delta so the user reviews the bump itself,
585- * not just the new tx in isolation. The original tx is identified by
586- * `txid`; `oldFeeSats` + `oldFeeRateSatPerVb` come from the indexer.
587- */
588- replaces ?: {
589- txid : string ;
590- oldFeeSats : string ;
591- oldFeeRateSatPerVb : number ;
592- } ;
593- /**
594- * Primary source address (the first entry in `sources` for multi-source
595- * sends, or the only source for single-source sends). Kept for
596- * backwards compat — handlers and the verification block treat this as
597- * the "from" label. Multi-source consumers should read `sources`.
598- */
599- from : string ;
600- /**
601- * All source addresses contributing UTXOs to this tx. One entry per
602- * unique source. Issue #264 — multi-input consolidation. For
603- * single-source sends this is a one-element array; the signer treats
604- * both shapes uniformly. All sources share `accountPath` +
605- * `addressFormat` (Phase 1 intra-account / uniform-type constraint).
606- */
607- sources : Array < {
608- address : string ;
609- /** Full leaf path of the source address, e.g. `84'/0'/0'/0/N`. */
610- path : string ;
611- /** Compressed (or uncompressed; signer compresses) public key hex. */
612- publicKey : string ;
613- } > ;
614- /**
615- * Per-PSBT-input source address — `inputSources[i]` names which entry
616- * in `sources` provided the i-th PSBT input. Used by the LTC legacy
617- * `createPaymentTransaction` fallback to populate `associatedKeysets`
618- * with the per-input path; the modern `signPsbtBuffer` path keys off
619- * the witness program in each input's `witnessUtxo` script and looks
620- * up the source via `knownAddressDerivations`. Length equals the PSBT
621- * input count, in PSBT input order.
622- */
623- inputSources : string [ ] ;
624- /** Base64-encoded PSBT v0 bytes. The device's `signPsbtBuffer` consumes this. */
625- psbtBase64 : string ;
626- /**
627- * BIP-32 account-level path (e.g. `m/84'/0'/0'`) the PSBT signs from.
628- * `signPsbtBuffer` requires this so it can populate missing BIP-32
629- * derivation info on the PSBT inputs.
630- */
631- accountPath : string ;
632- /**
633- * Address format the account uses — passed explicitly to
634- * `signPsbtBuffer.addressFormat`. "bech32" for native segwit, etc.
635- */
636- addressFormat : "legacy" | "p2sh" | "bech32" | "bech32m" ;
637- /**
638- * Internal-chain (BIP-32 chain=1) address the change output goes to,
639- * plus its derivation. Threaded to the signer so it can register the
640- * change output in `signPsbtBuffer.knownAddressDerivations` (and, for
641- * the legacy `createPaymentTransaction` fallback, populate
642- * `changePath`). Without this, the Ledger BTC app v2.x flags every
643- * change output as "unusual change path". Issue #254.
644- *
645- * Optional only for tx envelopes built by older code paths or by
646- * clients that pre-validated they want change-on-source — the modern
647- * Phase-1 builder always sets it.
648- */
649- change ?: {
650- address : string ;
651- /** Full leaf path of the change address, e.g. `84'/0'/0'/1/0`. */
652- path : string ;
653- /** Compressed (or uncompressed; signer compresses) public key hex. */
654- publicKey : string ;
655- } ;
656- /** Human-readable description for the preview. */
657- description : string ;
658- /** Decoded outputs + fee + RBF flag. The shape Ledger's screen mirrors. */
659- decoded : {
660- functionName : string ;
661- args : Record < string , string > ;
662- outputs : Array < {
663- address : string ;
664- amountSats : string ;
665- amountBtc : string ;
666- isChange : boolean ;
667- /** Path of the change output (when isChange=true), e.g. `m/84'/0'/0'/1/0`. */
668- changePath ?: string ;
669- } > ;
670- /**
671- * Per-source breakdown — one entry per unique source contributing a
672- * UTXO to this tx. Mirrors the verification-block "From: each source
673- * address with sats pulled" line (issue #264). Always populated;
674- * single-source sends produce a one-element array.
675- */
676- sources : Array < {
677- address : string ;
678- /** Total sats pulled from this source across all selected inputs. */
679- pulledSats : string ;
680- /** Same value as `pulledSats`, formatted as a BTC decimal string. */
681- pulledBtc : string ;
682- /** How many of the PSBT's inputs come from this source. */
683- inputCount : number ;
684- } > ;
685- feeSats : string ;
686- feeBtc : string ;
687- feeRateSatPerVb : number ;
688- /** Sequence number — < 0xFFFFFFFE marks the tx BIP-125 RBF-eligible. */
689- rbfEligible : boolean ;
690- } ;
691- /** Estimated tx vsize, used to derive the displayed feeRateSatPerVb. */
692- vsize : number ;
693- /** Opaque handle — see btc-tx-store.ts. send_transaction consumes this. */
694- handle ?: string ;
695- /**
696- * Domain-tagged sha256 over the PSBT base64. Pair-consistency
697- * anchor between prepare → preview → sign stages. NOT shown
698- * on-device (Ledger BTC clear-signs outputs; on-device anchor is
699- * address + amount per output).
700- */
701- fingerprint ?: `0x${string } `;
702- /**
703- * Address-book recipient metadata — see `UnsignedTx.recipient`.
704- * Populated when `args.to` matched a contact label (or reverse-
705- * decorated to a saved one). Threaded into the verification block.
706- */
707- recipient ?: {
708- label ?: string ;
709- source : "literal" | "contact" | "ens" | "unknown" ;
710- warnings ?: string [ ] ;
711- } ;
712- }
713-
714- /**
715- * Unsigned Litecoin transaction. Mirror of `UnsignedBitcoinTx` —
716- * same PSBT-v0 shape, same Ledger app interface (currency:"litecoin"
717- * on the SDK side selects Litecoin-specific encoding). Symbol fields
718- * use LTC, but the on-wire bytes (PSBT, raw tx hex) use the same
719- * format as BTC.
720- */
721- export interface UnsignedLitecoinTx {
722- chain : "litecoin" ;
723- action : "native_send" ;
724- from : string ;
725- /** See `UnsignedBitcoinTx.sources`. Issue #264. */
726- sources : Array < {
727- address : string ;
728- path : string ;
729- publicKey : string ;
730- } > ;
731- /** See `UnsignedBitcoinTx.inputSources`. Issue #264. */
732- inputSources : string [ ] ;
733- psbtBase64 : string ;
734- accountPath : string ;
735- addressFormat : "legacy" | "p2sh" | "bech32" | "bech32m" ;
736- /** See `UnsignedBitcoinTx.change`. Issue #254. */
737- change ?: {
738- address : string ;
739- path : string ;
740- publicKey : string ;
741- } ;
742- description : string ;
743- decoded : {
744- functionName : string ;
745- args : Record < string , string > ;
746- outputs : Array < {
747- address : string ;
748- amountSats : string ;
749- amountLtc : string ;
750- isChange : boolean ;
751- changePath ?: string ;
752- } > ;
753- /** See `UnsignedBitcoinTx.decoded.sources`. Issue #264. */
754- sources : Array < {
755- address : string ;
756- pulledSats : string ;
757- pulledLtc : string ;
758- inputCount : number ;
759- } > ;
760- feeSats : string ;
761- feeLtc : string ;
762- feeRateSatPerVb : number ;
763- rbfEligible : boolean ;
764- } ;
765- vsize : number ;
766- /** Opaque handle — see ltc-tx-store.ts. */
767- handle ?: string ;
768- fingerprint ?: `0x${string } `;
769- }
770-
771557export * from "./config.js" ;
0 commit comments