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

6
  • Does client.command('scantxoutset', 'start', [[ "desc" => "addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)" ]]) work? Aug 4, 2019 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, 2019 at 4:36
  • Oh, this is JS. Then it should be command('scantxoutset', 'start', [{"desc":"addr(...)"}]). Aug 4, 2019 at 5:35
  • @PieterWuille tried a couple variations of that with not luck as well. Question is updated to include them
    – Michael
    Aug 4, 2019 at 15:55
  • 1
    Are you on mainnet or testnet?
    – Ava Chow
    Aug 4, 2019 at 16:42

3 Answers 3

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.

0
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.

-1

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

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

10
  • 1
    Thanks, that looks right and may help some people. At least on my Linux box here, I can also get away without escaping the inner double-quotes by using single-quotes around the scanobjects: scantxoutset start '["addr(37HyJsnuP5zWTuhJFvrGNYojtmBFnZYoFR)"]'.
    – Murch
    Jul 17, 2023 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)]' Jul 22, 2023 at 11:36
  • Murch, maybe go on strike like your name suggests because your downvote is downright WRONG Jul 22, 2023 at 11:37
  • 1
    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, 2023 at 13:04
  • Well thanks for upvoting the only answer that worked for me. Yes people don't want to know ideas, they want a belief in authority so they don't have to think.. anyway for anyone that wants an answer that works, there it is. just had to use this again yesterday.. even chatGPT gives a bunch of wrong answers Sep 22, 2023 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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