# @dgb-wallet/psbt DigiByte transaction construction and signing via PSBT (BIP174). - `buildPsbt({ inputs, outputs })` — construct an unsigned PSBT from UTXOs and outputs, BIP69 sorted by default - `signAllInputs(psbt, keyPair)` — sign every input with an ECPair; fails loudly if any input can't be signed - `finalizeAndExtract(psbt)` — after signing, produce broadcast-ready `{ hex, txid }` - `feeSats(psbt)` / `feeRateSatsPerByte(psbt)` — inspect fee before broadcasting Supports BIP44 (P2PKH), BIP49 (P2SH-P2WPKH), BIP84 (P2WPKH), BIP86 (P2TR) inputs. Depends on `@dgb-wallet/core` for network params. ## Demo ```bash cd "D:\Dev\SilentCode\Digibyte" npm install # first time only, sets up the workspace npm run demo -w @dgb-wallet/psbt ``` Derives a key from the public BIP39 test seed, constructs a PSBT spending a synthetic UTXO to two outputs, signs it, and prints the raw transaction hex. The UTXO is fake so this cannot be broadcast — but every other step (derivation, PSBT construction, signature, finalization) is real and identical to what a broadcastable transaction would use. Feed a real UTXO from `scantxoutset` / Blockbook / Electrum-DGB and the same code produces a live transaction. ## Layout ``` src/ types.ts — Utxo, Output, BuildParams shapes build.ts — buildPsbt with BIP69 sorting sign.ts — signAllInputs, finalizeAndExtract, fee inspection index.ts — re-exports scripts/ build-tx-demo.ts — end-to-end seed → signed-tx demo ```