How to use `scantxoutset`

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

Michael

Posted 2019-08-04T04:11:03.667

Reputation: 131

Does client.command('scantxoutset', 'start', [[ "desc" => "addr(34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo)" ]]) work?Pieter Wuille 2019-08-04T04:26:56.900

@PieterWuille it does not :`( As you have written there would be invalid syntax as well. Updated post to include those attemptsMichael 2019-08-04T04:36:22.793

Oh, this is JS. Then it should be command('scantxoutset', 'start', [{"desc":"addr(...)"}]).Pieter Wuille 2019-08-04T05:35:05.243

@PieterWuille tried a couple variations of that with not luck as well. Question is updated to include themMichael 2019-08-04T15:55:39.780

Are you on mainnet or testnet?Andrew Chow 2019-08-04T16:42:04.540

testnet @AndrewChowMichael 2019-08-04T16:47:37.270

Answers

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.

Michael

Posted 2019-08-04T04:11:03.667

Reputation: 131

1

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

Posted 2019-08-04T04:11:03.667

Reputation: 40 910

Yep, just found that out! Thank youMichael 2019-08-04T16:51:23.770