psbt
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePSBT Skill
PSBT 工具
Provides PSBT (Partially Signed Bitcoin Transaction) construction and signing operations on the Bitcoin L1. PSBTs enable multi-party signing workflows such as ordinals marketplace purchases where both buyer and seller must sign before broadcast.
- estimate-fee — Read-only fee estimation for a PSBT given its structure.
- sign — Sign one or more PSBT inputs with the active unlocked wallet (P2WPKH or Taproot keys).
- broadcast — Finalize a fully signed PSBT and broadcast it to the Bitcoin network via mempool.space.
在比特币L1上提供PSBT(部分签名比特币交易)的构建与签名操作。PSBT支持多方签名工作流,例如铭文市场交易中,买卖双方必须在广播前完成签名。
- estimate-fee — 根据PSBT的结构进行只读手续费估算。
- sign — 使用已解锁的活跃钱包(P2WPKH或Taproot密钥)对一个或多个PSBT输入进行签名。
- broadcast — 完成已全签名PSBT的最终处理,并通过mempool.space将其广播至比特币网络。
Usage
使用方法
bun run psbt/psbt.ts <subcommand> [options]bun run psbt/psbt.ts <subcommand> [options]Subcommands
子命令
estimate-fee
estimate-fee
Estimate the network fee in satoshis for a given PSBT. Parses the transaction structure and computes vsize-based fee estimate for fast, medium, and slow fee tiers.
bun run psbt/psbt.ts estimate-fee --psbt <base64>Options:
- (required) — PSBT in base64 format
--psbt <base64>
Output:
json
{
"network": "mainnet",
"vsize": 253,
"inputsLength": 2,
"outputsLength": 3,
"feeEstimates": {
"fast": { "satPerVb": 12, "totalSats": 3036 },
"medium": { "satPerVb": 6, "totalSats": 1518 },
"slow": { "satPerVb": 2, "totalSats": 506 }
},
"currentFeeSats": "1200"
}估算给定PSBT的网络手续费(单位:聪)。解析交易结构,并基于vsize计算快速、中等和慢速三个手续费档位的估算值。
bun run psbt/psbt.ts estimate-fee --psbt <base64>选项:
- (必填)—— base64格式的PSBT
--psbt <base64>
输出:
json
{
"network": "mainnet",
"vsize": 253,
"inputsLength": 2,
"outputsLength": 3,
"feeEstimates": {
"fast": { "satPerVb": 12, "totalSats": 3036 },
"medium": { "satPerVb": 6, "totalSats": 1518 },
"slow": { "satPerVb": 2, "totalSats": 506 }
},
"currentFeeSats": "1200"
}sign
sign
Sign PSBT inputs with the active wallet's BTC private keys (P2WPKH and/or Taproot). The wallet must be unlocked before calling this subcommand.
bun run psbt/psbt.ts sign --psbt <base64>Options:
- (required) — PSBT in base64 format to sign
--psbt <base64> - (optional) — Comma-separated input indexes to sign (signs all signable inputs if omitted)
--inputs <indexes> - (optional) — Finalize signed inputs immediately (default: false)
--finalize
Output:
json
{
"success": true,
"network": "mainnet",
"signedInputs": [1, 2],
"finalizedInputs": [],
"skippedInputs": [{ "index": 0, "reason": "no matching key for this input" }],
"psbtBase64": "<updated-base64>"
}使用活跃钱包的BTC私钥(P2WPKH和/或Taproot)对PSBT输入进行签名。调用此子命令前必须解锁钱包。
bun run psbt/psbt.ts sign --psbt <base64>选项:
- (必填)—— 待签名的base64格式PSBT
--psbt <base64> - (可选)—— 待签名的输入索引(逗号分隔,若省略则对所有可签名输入进行签名)
--inputs <indexes> - (可选)—— 立即完成已签名输入的最终处理(默认:false)
--finalize
输出:
json
{
"success": true,
"network": "mainnet",
"signedInputs": [1, 2],
"finalizedInputs": [],
"skippedInputs": [{ "index": 0, "reason": "no matching key for this input" }],
"psbtBase64": "<updated-base64>"
}broadcast
broadcast
Finalize a fully signed PSBT and broadcast it to the Bitcoin network via mempool.space.
bun run psbt/psbt.ts broadcast --psbt <base64>Options:
- (required) — Fully signed PSBT in base64 format
--psbt <base64>
Output:
json
{
"success": true,
"network": "mainnet",
"txid": "abc123...",
"explorerUrl": "https://mempool.space/tx/abc123...",
"txHex": "0200..."
}完成已全签名PSBT的最终处理,并通过mempool.space将其广播至比特币网络。
bun run psbt/psbt.ts broadcast --psbt <base64>选项:
- (必填)—— 已全签名的base64格式PSBT
--psbt <base64>
输出:
json
{
"success": true,
"network": "mainnet",
"txid": "abc123...",
"explorerUrl": "https://mempool.space/tx/abc123...",
"txHex": "0200..."
}Notes
注意事项
- Wallet must be unlocked with before calling
bun run wallet/wallet.ts unlock.sign - For ordinals purchase PSBTs (built by the MCP tool ): input index 0 is the seller's inscription UTXO; buyer inputs start at index 1. Sign only buyer inputs (index 1+) unless you are the seller.
psbt_create_ordinal_buy - calls
broadcast— all inputs must be fully signed or it will throw.tx.finalize() - Fee estimates in are based on the PSBT's current vsize; they reflect the signed transaction size, not the unsigned size.
estimate-fee
- 调用前,必须通过
sign解锁钱包。bun run wallet/wallet.ts unlock - 对于由MCP工具创建的铭文交易PSBT:输入索引0是卖家的铭文UTXO;买家输入从索引1开始。除非你是卖家,否则仅对买家输入(索引1及以上)进行签名。
psbt_create_ordinal_buy - 会调用
broadcast——所有输入必须已完全签名,否则会抛出错误。tx.finalize() - 中的手续费估算基于PSBT当前的vsize;反映的是已签名交易的大小,而非未签名交易的大小。
estimate-fee