Bitcoin Forum
April 18, 2024, 07:17:56 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: gettransaction for non-wallet transactions?  (Read 1745 times)
Herbert (OP)
Hero Member
*****
Offline Offline

Activity: 488
Merit: 500



View Profile WWW
December 07, 2011, 11:55:21 AM
 #1

Hi,

I understand that the gettransactions command only will return transactions concerning the users wallet. Is there a way to query bitcoind for any transaction, independent of the users wallet?

Thanks!

www.bitcoinmonitor.net - Free payment notification via email, newsfeed, xpmm/jabber, url callback and full API access!
Send SMS with www.txt4coins.net! No registration, pay-per-use, full API access, bulk messages - All inclusive!
1713467876
Hero Member
*
Offline Offline

Posts: 1713467876

View Profile Personal Message (Offline)

Ignore
1713467876
Reply with quote  #2

1713467876
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.
1713467876
Hero Member
*
Offline Offline

Posts: 1713467876

View Profile Personal Message (Offline)

Ignore
1713467876
Reply with quote  #2

1713467876
Report to moderator
1713467876
Hero Member
*
Offline Offline

Posts: 1713467876

View Profile Personal Message (Offline)

Ignore
1713467876
Reply with quote  #2

1713467876
Report to moderator
etotheipi
Legendary
*
expert
Offline Offline

Activity: 1428
Merit: 1093


Core Armory Developer


View Profile WWW
December 07, 2011, 01:26:16 PM
 #2

Your bitcoind would have to do a full rescan of the blockchain, which it is probably prohibitively slow in the Satoshi client.  I'm sure the client could be hacked to do this, though.

Founder and CEO of Armory Technologies, Inc.
Armory Bitcoin Wallet: Bringing cold storage to the average user!
Only use Armory software signed by the Armory Offline Signing Key (0x98832223)

Please donate to the Armory project by clicking here!    (or donate directly via 1QBDLYTDFHHZAABYSKGKPWKLSXZWCCJQBX -- yes, it's a real address!)
dogisland
Sr. Member
****
Offline Offline

Activity: 262
Merit: 250



View Profile
December 07, 2011, 01:52:54 PM
 #3

There's an import/export private key patch.

https://bitcointalk.org/index.php?topic=8091.0

I believe this does a rescan on each import.
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
December 07, 2011, 03:31:41 PM
 #4

Not true, you don't need a rescan to find an arbitrary transaction, if you have the block chain database. It's just not implemented.

I do Bitcoin stuff.
etotheipi
Legendary
*
expert
Offline Offline

Activity: 1428
Merit: 1093


Core Armory Developer


View Profile WWW
December 07, 2011, 07:18:57 PM
 #5

Not true, you don't need a rescan to find an arbitrary transaction, if you have the block chain database. It's just not implemented.


My bad.  I thought you asked about looking up transactions for a given address.  It sounds like you have a tx hash and you want to retrieve the tx.  Yes, that should be an easy modification to bitcoind.

Founder and CEO of Armory Technologies, Inc.
Armory Bitcoin Wallet: Bringing cold storage to the average user!
Only use Armory software signed by the Armory Offline Signing Key (0x98832223)

Please donate to the Armory project by clicking here!    (or donate directly via 1QBDLYTDFHHZAABYSKGKPWKLSXZWCCJQBX -- yes, it's a real address!)
Herbert (OP)
Hero Member
*****
Offline Offline

Activity: 488
Merit: 500



View Profile WWW
December 08, 2011, 04:13:53 PM
 #6

It sounds like you have a tx hash and you want to retrieve the tx.  Yes, that should be an easy modification to bitcoind.

Yes, that's what i want to do.

Glancing at the code the current implementation is completely wallet-centric. GetTransaction() from main.cpp walks through all wallets and calls wallet->getTransaction(), and also returns wallet-specific CWalletTx object. So it does not really look like a trivial patch :-/

Is there already a patch existing somewhere providing this feature? Alternatively any hints where i should start doing my own patch are welcome ;-)

www.bitcoinmonitor.net - Free payment notification via email, newsfeed, xpmm/jabber, url callback and full API access!
Send SMS with www.txt4coins.net! No registration, pay-per-use, full API access, bulk messages - All inclusive!
blueadept
Full Member
***
Offline Offline

Activity: 225
Merit: 101


View Profile
December 08, 2011, 04:39:13 PM
 #7

It sounds like you have a tx hash and you want to retrieve the tx.  Yes, that should be an easy modification to bitcoind.

Yes, that's what i want to do.

Glancing at the code the current implementation is completely wallet-centric. GetTransaction() from main.cpp walks through all wallets and calls wallet->getTransaction(), and also returns wallet-specific CWalletTx object. So it does not really look like a trivial patch :-/

Is there already a patch existing somewhere providing this feature? Alternatively any hints where i should start doing my own patch are welcome ;-)

I'm not super familiar with the code, but non-wallet transactions HAVE TO BE indexed for validation of incoming transactions/blocks.  Each new transaction contains inputs which are outputs of previous transactions, referenced by the hash of the previous transaction and the index of the output used as the input so fast lookup is essential for validating new transactions/blocks.  You're more likely to find what you want in db.h and db.cpp (look for CTxDB::ReadDiskTx(...) methods).

Like my posts?  Connect with me on LinkedIn and endorse my "Bitcoin" skill.
Decentralized, instant off-chain payments.
Herbert (OP)
Hero Member
*****
Offline Offline

Activity: 488
Merit: 500



View Profile WWW
December 08, 2011, 09:44:31 PM
Last edit: December 08, 2011, 10:02:43 PM by Herbert
 #8

Cool, got it working :-)

CMerkleTx is the class to use:
Code:
// construct COutPoint to satisfy ReadFromDisk method
COutPoint dummyOutp(hash, 0);
CMerkleTx mtx;
mtx.ReadFromDisk(dummyOutp);
mtx.SetMerkleBranch(NULL);
Passing NULL into SetMerkleBranch actually triggers reading/loading it from the transactionDB. Spent some time thinking how to obtain a CBlock* untill i realized that  Roll Eyes

Wrapped this up in some rpc glue code and got my shiny new "getanytransaction" rpc command running  Grin

Thanks for your help!

Edit:
In case someone finds this usefull - the code is on github: https://github.com/TripleSpeeder/bitcoin


www.bitcoinmonitor.net - Free payment notification via email, newsfeed, xpmm/jabber, url callback and full API access!
Send SMS with www.txt4coins.net! No registration, pay-per-use, full API access, bulk messages - All inclusive!
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!