Author

Topic: gettransaction for non-wallet transactions? (Read 1757 times)

hero member
Activity: 488
Merit: 500
December 08, 2011, 04:44:31 PM
#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

full member
Activity: 225
Merit: 101
December 08, 2011, 11:39:13 AM
#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).
hero member
Activity: 488
Merit: 500
December 08, 2011, 11:13:53 AM
#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 ;-)
legendary
Activity: 1428
Merit: 1093
Core Armory Developer
December 07, 2011, 02: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.
legendary
Activity: 1072
Merit: 1189
December 07, 2011, 10:31:41 AM
#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.
sr. member
Activity: 262
Merit: 250
December 07, 2011, 08:52:54 AM
#3
There's an import/export private key patch.

https://bitcointalksearch.org/topic/pull-private-key-and-wallet-exportimport-8091

I believe this does a rescan on each import.
legendary
Activity: 1428
Merit: 1093
Core Armory Developer
December 07, 2011, 08:26:16 AM
#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.
hero member
Activity: 488
Merit: 500
December 07, 2011, 06: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!
Jump to: