Bitcoin Forum
May 06, 2024, 04:44:36 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [Bitcoin Core] How to know TXID which moves funds of one of your transactions?  (Read 170 times)
d5000 (OP)
Legendary
*
Offline Offline

Activity: 3906
Merit: 6194


Decentralization Maximalist


View Profile
November 27, 2020, 01:23:49 AM
 #1

I have a question for the following scenario for Bitcoin Core:

Let's say I transfer funds to an address which is not under my control and also not in my wallet as a watchonly address (Transaction A). Now the person owning that address transfers the funds to another address (Transaction B).

Is there a way, only using Bitcoin Core commands (i.e. without importing the address where I sent the coins as watchonly, nor using a block explorer, etc.), to know the TXID of Transaction B?

My only idea would be to manually check all blocks which were added to the blockchain after the transaction was sent (with the getblock command) but is there a more efficient/simpler way?

I have no idea how to google that, so if this has already been answered here (or at Stackexchange etc.) I'll be grateful for a link. Smiley

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
1715013876
Hero Member
*
Offline Offline

Posts: 1715013876

View Profile Personal Message (Offline)

Ignore
1715013876
Reply with quote  #2

1715013876
Report to moderator
1715013876
Hero Member
*
Offline Offline

Posts: 1715013876

View Profile Personal Message (Offline)

Ignore
1715013876
Reply with quote  #2

1715013876
Report to moderator
Make sure you back up your wallet regularly! Unlike a bank account, nobody can help you if you lose access to your BTC.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715013876
Hero Member
*
Offline Offline

Posts: 1715013876

View Profile Personal Message (Offline)

Ignore
1715013876
Reply with quote  #2

1715013876
Report to moderator
1715013876
Hero Member
*
Offline Offline

Posts: 1715013876

View Profile Personal Message (Offline)

Ignore
1715013876
Reply with quote  #2

1715013876
Report to moderator
1715013876
Hero Member
*
Offline Offline

Posts: 1715013876

View Profile Personal Message (Offline)

Ignore
1715013876
Reply with quote  #2

1715013876
Report to moderator
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
November 27, 2020, 01:18:30 PM
Merited by d5000 (1), ABCbits (1), AdolfinWolf (1)
 #2

Depends on your node.

If you have indexed all transactions (-txindex flag), then definitely.
If you didn't, i doubt that's possible the way you imagine (not sure tho).

NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6728


bitcoincleanup.com / bitmixlist.org


View Profile WWW
November 27, 2020, 02:49:50 PM
 #3

Grabbing all the transactions from getblock is basically what block explorers do in their backends except they then take the result apart and store them in different databases.

Without doing that or using -txindex, you can only go as far as getting the receiving address of Transaction A, via the gettxout command.

The issue here, now, is to find all the transactions (or at least the most recent ones) of receiving address A without using getblock.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
d5000 (OP)
Legendary
*
Offline Offline

Activity: 3906
Merit: 6194


Decentralization Maximalist


View Profile
November 27, 2020, 03:18:36 PM
 #4

Thanks already.

There was a post by @AdolfinWolf here which was quite useful (although it doesn't solve the problem completely), was it deleted? (I tried to give it a merit, but then it didn't allow me to do that and finally disappeared ...)

scantxoutset also was crossing my mind but the problem is that (as far as I understand) once the funds are moved again and confirmed (which would be Transaction C using funds of transaction B) then the output obviously isn't an UTXO anymore and would not get listed.

-txindex=1 would be an option to consider. But how would the command look like then? Can I do "listreceivedbyaddress ADDRESS" with the "destination address" of transaction A, like I could do when I imported the address as a watchonly address?

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
AdolfinWolf
Legendary
*
Offline Offline

Activity: 1946
Merit: 1427


View Profile
November 27, 2020, 04:21:23 PM
Merited by d5000 (1)
 #5

-txindex=1 would be an option to consider. But how would the command look like then? Can I do "listreceivedbyaddress ADDRESS" with the "destination address" of transaction A, like I could do when I imported the address as a watchonly address?
I removed my post because it seemed* that the problem can be solved much easier, although I sorta doubt this now reading a bit more. ( I can't test this because I'm running a pruned node.)

It seems to me that even with txindex=1 you'll just get stuck after using getrawtransaction / gettxout on TXID A. This will just return information on the address/ txid A.

Now you're stuck, because even with txindex=1, you cannot use something like scantxoutset,  (because the input is spent), and you cannot use something like getreceivedbyaddress/listreceivedbyaddress because it only works for your own wallet[1], that is according to sources, (I have not tested this..).

[1] https://bitcoin.stackexchange.com/questions/53496/bitcoind-change-to-txindex-1#comment62179_53497

So really, the only functionality that changes by using txindex=1 is that of the getrawtransaction call (?).

nc50lc
Legendary
*
Offline Offline

Activity: 2408
Merit: 5588


Self-proclaimed Genius


View Profile
November 28, 2020, 03:23:19 AM
Merited by AdolfinWolf (1)
 #6

getreceivedbyaddress/listreceivedbyaddress because it only works for your own wallet[1], that is according to sources, (I have not tested this..).
That's correct, you'll get an error message: Address not found in wallet (code -4) when using "getreceivedbyaddress" even with -txindex.
"listreceivedbyaddress" on the other hand, doesn't take an address argument.

The only alternative solution I can think of is to have your own expensive database like that of a blockexplorer.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
November 28, 2020, 02:06:02 PM
 #7

It seems to me that even with txindex=1 you'll just get stuck after using getrawtransaction / gettxout on TXID A. This will just return information on the address/ txid A.

With -txindex used, you are able to build your own database of all transactions.
Then a simple search for the desired address can yield the result you are interested in.

This wouldn't even be lots of coding, just a small script to store and search for the required information.

d5000 (OP)
Legendary
*
Offline Offline

Activity: 3906
Merit: 6194


Decentralization Maximalist


View Profile
November 30, 2020, 03:37:43 PM
 #8

With -txindex used, you are able to build your own database of all transactions.
Then a simple search for the desired address can yield the result you are interested in.

This wouldn't even be lots of coding, just a small script to store and search for the required information.
Yes, but then I would need to add an own database. In this case I guess I could also simply scan all the blocks and build the database from there, which would be not that much more resource consuming.

I've searched the Web a bit and found this pull request review for Bitcoin Core from January. This would add the "search by address" feature needed for this kind of query. But it's still not implemented, and there seem to be some valid arguments against it (mostly, that an address index does not scale).

I have realized that without this kind of index the request I wanted is simply not possible in an efficient way, due to the structure of the Bitcoin Core database, because a transaction, apart from the address/pubkeyhash, doesn't hold information which could be useful to query subsequent transactions.

The only other strategy which could be possible is to build a database of TXIDs used in inputs of other transactions, which would make this query also possible ("query al txes where the TXID of Transaction A was used in inputs"), but I haven't found any information about that.

The best strategy without address database and without additional tools for now imo would be this one:

- if the transaction was recently, try scantxoutset
- if this gives no results: from the timestamp of Transaction A on, scan all blocks.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!