1

Looking to fetch the UTXOs for a given address and can't seem to find the correct command syntax.

Here is an implementation in bitcoin-core via javascript, but I also experience the same on bitcoin-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)
    })
})

All result in RpcError: Invalid descriptor

  • Does client.command('scantxoutset', 'start', [[ "desc" => "addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)" ]]) work? – Pieter Wuille Aug 4 '19 at 4:26
  • @PieterWuille it does not :`( As you have written there would be invalid syntax as well. Updated post to include those attempts – Michael Aug 4 '19 at 4:36
  • Oh, this is JS. Then it should be command('scantxoutset', 'start', [{"desc":"addr(...)"}]). – Pieter Wuille Aug 4 '19 at 5:35
  • @PieterWuille tried a couple variations of that with not luck as well. Question is updated to include them – Michael Aug 4 '19 at 15:55
  • Are you on mainnet or testnet? – Andrew Chow Aug 4 '19 at 16:42
3

You are trying to use a mainnet encoded address on testnet. That is not valid. You need to use a testnet encoded address.

The testnet form of the address you are trying to use is 2MvX28fMpoipKxqaxo6pN1CH4QjB5t9qpr8.

| improve this answer | |
  • Yep, just found that out! Thank you – Michael Aug 4 '19 at 16:51
2

I resolved this.

Here is the functional command:

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

The issue is that the address was invalid. Using a valid address, I can ensure that this works.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.