3

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

Murch
  • 71,155
  • 33
  • 180
  • 600
Michael
  • 173
  • 8

3 Answers3

4

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.

Andrew Chow
  • 67,209
  • 5
  • 76
  • 149
3

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.

Michael
  • 173
  • 8
-1

when using bitcoin-cli on command line, a syntax that works is

scantxoutset start "[\"addr(37HyJsnuP5zWTuhJFvrGNYojtmBFnZYoFR)\"]"

Murch
  • 71,155
  • 33
  • 180
  • 600
  • 1
    You should be able to get away without escaping the inner double-quotes if you use single-quotes around the scanobjects: `scantxoutset start '["addr(37HyJsnuP5zWTuhJFvrGNYojtmBFnZYoFR)"]'` – Murch Jul 17 '23 at 20:20
  • Uh, thanks for downvoting but I jsut tried your answer and it didn't work, whereas my answer does work Murch. Your answer gives the error: `error: Error parsing JSON: '[addr(37HyJsnuP5zWTuhJFvrGNYojtmBFnZYoFR)]'` – Captain Fantastic Jul 22 '23 at 11:36
  • Murch, maybe go on strike like your name suggests because your downvote is downright WRONG – Captain Fantastic Jul 22 '23 at 11:37
  • I was in fact not one of the users that downvoted your answer, but the one that upvoted it, because it looked right to me… I was merely suggesting another avenue that may work without the escaping (which appears in the rpc doc, and works on my machine). For what it’s worth, the input requirements on RPC commands are pretty confusing. Either way, I think people are downvoting this answer because it’s attacking people instead of ideas, not because it’s incorrect. – Murch Jul 22 '23 at 13:04