Address

如何使用scantxoutset

  • October 10, 2020

希望獲取給定地址的 UTXO,但似乎找不到正確的命令語法。

這是通過 javascript 在比特幣核心中的實現,但我在比特幣 cli 上也遇到了同樣的情況

const descriptorAttempts = [
   '{ desc: addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo) }', 
   '{ "desc": "addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)" }', 
   '"desc": "addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)"', 
   "addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)", 
   "addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)", 
   "addr=34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo", 
   "34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo", 
   "{ addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo) }", 
   "{ addr: 34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo }",
   "{\"desc\": \"addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)\"}",
   '\"{\"desc": \"addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)\"}\"',
   '"{"desc": "addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)"}"',
   '"{"desc": "addr("34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo")"}"',
   '\"{\"desc": \"addr(\"34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo\")\"}\"',
   '"desc" => "addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)"',
   '[ "desc" => "addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)" ]',
   { "desc" : "addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)" },
   { desc : "addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)" }
]

descriptorAttempts.forEach(attempt => {
   client.command('scantxoutset', 'start', [ attempt ])
   .then((res) => {
       console.log("Success! 🙌")
       console.log(res)
   })
   .catch((error) => {
       console.log("Failed attempt of -> " + attempt)
       // console.log(error)
   })
})

所有結果RpcError: Invalid descriptor

您正在嘗試在測試網上使用主網編碼地址。那是無效的。您需要使用測試網編碼地址。

您嘗試使用的地址的測試網形式是2MvX28fMpoipKxqaxo6pN1CH4QjB5t9qpr8.

我解決了這個問題。

這是功能命令:

client.command('scantxoutset', 'start' ['addr(mfe87Qheq7SSveCDedyDUBEjMD9tgzRiU7)']) <!-- Address is valid. This address: '34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo' is invalid

問題是地址無效。使用有效的地址,我可以確保它有效。

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