create_tx accepts recipient addresses from the wrong network
維護者通常 2 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從 issue 中提到的兩個位置 CreateTxCommand 和 parse_recipient 開始。追蹤 parse_recipient 如何將收款方轉換為腳本,以及 execute 如何存取錢包網路;檢查現有的 BDKCliError 定義中關於 InvalidNetwork 的內容。完成標準是:create_tx 在產生 PSBT 之前,以該特定錯誤拒絕來自其他網路的地址。
由索引模型根據 Issue 內容生成。
描述
Describe the bug
create_tx accepts a recipient address belonging to a different network than the wallet. The transaction is built successfully, but the resulting PSBT is unspendable on the target network and only fails later at broadcast time with a node-side rejection. The cause is in parse_recipient: it calls Address::from_str (which yields Address<NetworkUnchecked>) and immediately converts to ScriptBuf via .script_pubkey(), discarding the network information before the wallet's network is known. bdk-cli therefore never compares the two.
To Reproduce
- Create a regtest wallet:
bdk-cli --network regtest wallet -w regtest_user1 --descriptor "..." --change_descriptor "..." create - Attempt to send to a testnet address:
bdk-cli --network regtest wallet -w regtest_user1 create_tx --to tb1qdgxnu...:1000 - Observe: the command succeeds and returns a PSBT.
- Broadcasting that PSBT against the regtest node fails with an address/script error, because
tb1...does not belong to the regtest network.
Expected behavior
create_tx should reject the recipient at construction time with a specific error naming the mismatch, rather than producing a PSBT that can never be spent. BDKCliError::InvalidNetwork { requested, found } should be created for this purpose. The recipient should be carried through as Address<NetworkUnchecked> and validated with require_network(ctx.state.wallet.network()) inside execute, immediately before conversion to ScriptBuf.
Build environment
- BDK-CLI tag/commit:
main - OS+version: macOS 12.7.6 (Monterey)
- Rust/Cargo version:
rustc --versionoutput - Rust/Cargo target:
x86_64-apple-darwin
Additional context
The fix is confined to CreateTxCommand and parse_recipient; no changes to the wallet API are needed.
- 主要語言
- Rust
- 星號
- 143
- 分支
- 103
- 平均合併
- 2 天 9 小時
- 30 天內合併 PR
- 5
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
bitcoindevkit/bdk-cli 的其他 Issue
-
enhancement
難度 2/5 1-3 小時 新手友好度 78/100
bitcoindevkit/bdk-cli#358 ·
維護者通常 2 天內回覆
-
wallet sign command returns generic error for decoding failures可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉bug
難度 2/5 1-3 小時 新手友好度 72/100
bitcoindevkit/bdk-cli#357 ·
維護者通常 2 天內回覆
-
Remove "wallet" field from `WalletConfigInner`可能已有人在做 @Jennycj 於 8 天前認領。 未關閉enhancement
難度 2/5 1-3 小時 新手友好度 72/100
bitcoindevkit/bdk-cli#332 · 2 則留言 ·
維護者通常 2 天內回覆
-
enhancement
難度 3/5 1-2 天 新手友好度 55/100
bitcoindevkit/bdk-cli#359 ·
維護者通常 2 天內回覆
-
Add wallet commands that returns a list of unused addresses可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉enhancement
難度 3/5 1-2 天 新手友好度 38/100
bitcoindevkit/bdk-cli#349 ·
維護者通常 2 天內回覆
查看 bitcoindevkit/bdk-cli 的全部 Issue
相似的 Issue
-
enhancement
難度 2/5 1-3 小時 新手友好度 68/100
metasequoiaime/msime#9113 ·
維護者通常 1 天內回覆
-
area:desktop priority:p2 type:chore
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
area: supply-chain
難度 1/5 1 小時以內 新手友好度 73/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 67/100
-
難度 1/5 1-3 小時 新手友好度 67/100
OpenCarControls/firmware#35 ·