Coder Social home page Coder Social logo

Comments (4)

chris-belcher avatar chris-belcher commented on August 26, 2024

Notes on bitcoind RPC.

To lookup UTXOs on an address, you indeed need to importprivkey them and then listunspent.
This can take a long time, of course. However since we only need to do it once at the beginning before the bot connects to IRC, it not too much of a problem to have a long lookup sequence. I imagine the watch-only addresses feature of the new bitcoind is just a way of doing this without having to know the private key.

Using -txindex you can look up any txid and get a transaction back, using gettransaction or getrawtransaction. Very useful, for privacy too since the status quo involves leaking which addresses you're interested in to blockr.

Apparently getrawtransaction queries the mempool (unconfirmed tx) and the txindex.

You can use -blocknotify to be notified when a new block arrives, you get given the blockhash as an argument, which you can pass to getblock, that will give you a list of TXIDs which you can pass to gettransaction. In this way you can learn when a transaction has been confirmed.

A way to learn when a transaction is unconfirmed could be to importprivkey with rescan=false and then check with -walletnotify. According to this bitcointalk post we could use walletnotify for both unconfirmed and confirmed.

The gettxout call might be useful for finding unconfirmed transactions too, there is an option includemempool=true. Worth investigating.

from joinmarket.

AdamISZ avatar AdamISZ commented on August 26, 2024

Thanks for that.

Yes, watchonly means you don't need to import the privkey. Maybe that doesn't really matter.

As I was mentioning on IRC, we also need to check spent txos as well as utxos, at least at startup to check for used status. To do this I used the listtransactions RPC call applied to a separate 'watchonly' account, and then filtered the output by address. I don't think the indexes can help with that (?) - getting all transactions (not just utxos) on a per-address basis, if you don't have the txids?

You can use -blocknotify to be notified when a new block arrives, you get given the blockhash as an argument, which you can pass to getblock, that will give you a list of TXIDs which you can pass to gettransaction. In this way you can learn when a transaction has been confirmed.

Ah, this is cool, will read up on it. You can easily get unconfirmed utxos with listunspent, but for mainnet (rather than regtest), this blocknotify feature could be very important.

from joinmarket.

chris-belcher avatar chris-belcher commented on August 26, 2024

The watchonly thing will be useful so a copy of the private key isnt also floating around in someone's wallet.dat file ready to be stolen.

I think -walletnotify might end up being all we need. Since it notifies us for both unconfirmed and confirmed.

from joinmarket.

chris-belcher avatar chris-belcher commented on August 26, 2024

Done with d4fa387

from joinmarket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.