Output-Script-Descriptors

導入描述符時的最小範圍?

  • October 28, 2022

導入範圍小於 1000 的描述符時,似乎會被忽略。這是故意的嗎?我在docs中找不到任何關於此的內容。

要重現,首先,創建一個空錢包:

bitcoin-cli -regtest -named createwallet wallet_name=test disable_private_keys=true blank=true descriptors=true

導入範圍為 10 的描述符:

bitcoin-cli -regtest -named importdescriptors requests='[{ "desc": "'"wpkh([9a6a2580/84'/1'/179']tpubDCMRAYcH71Gib1rASZpnMPpJbj7S1Nzmao1nPv5Jrb8pwSUimsH5TmK842UhnGPJbiNThzxhK4BpRUCsjSckpNYkH9kjKGWLd94yhZFN94J/0/*)#rljv8npg"'", "timestamp":"now", "active": true, "range":10}]'

檢查範圍listdescriptors

{
 "wallet_name": "test",
 "descriptors": [
   {
     "desc": "wpkh([9a6a2580/84'/1'/179']tpubDCMRAYcH71Gib1rASZpnMPpJbj7S1Nzmao1nPv5Jrb8pwSUimsH5TmK842UhnGPJbiNThzxhK4BpRUCsjSckpNYkH9kjKGWLd94yhZFN94J/0/*)#rljv8npg",
     "timestamp": 1666876980,
     "active": true,
     "internal": false,
     "range": [
       0,
       999
     ],
     "next": 0
   }
 ]
}

相比之下,如果我導入範圍大於 1000 的描述符,它似乎受到尊重:

bitcoin-cli -regtest -named importdescriptors requests='[{ "desc": "'"wpkh([9a6a2580/84'/1'/180']tpubDCMRAYcH71GibuLuWcDkwmmY1gXkXhf162QuEHxkMpZPSi7xck2eGQ6MRGKxNTeY8P1FiFTPCLA5x7qZpFx84fnnrNQFpSnUCwd1nPG8Mk9/0/*)#u49n3vuy"'", "timestamp":"now", "active": true, "range":2000}]'

再次檢查範圍listdescriptors

(…)
{
     "desc": "wpkh([9a6a2580/84'/1'/180']tpubDCMRAYcH71GibuLuWcDkwmmY1gXkXhf162QuEHxkMpZPSi7xck2eGQ6MRGKxNTeY8P1FiFTPCLA5x7qZpFx84fnnrNQFpSnUCwd1nPG8Mk9/0/*)#u49n3vuy",
     "timestamp": 1666876980,
     "active": true,
     "internal": false,
     "range": [
       0,
       2000
     ],
     "next": 0
   }

每次我們呼叫該DescriptorScriptPubKeyMan::TopUp方法時(這在內部發生了很多,包括每當我們添加新描述符時),它會自動調整range-end 至少與(下一個索引 + 密鑰池大小)一樣大。

如果您啟動 bitcoind 並指定keypool小於您要使用的範圍(例如bitcoind -regtest -keypool=5),您將觀察到您預期的行為。

(感謝您提供重現的步驟。)

引用自:https://bitcoin.stackexchange.com/questions/115747