Peercoin0.3.2 RPC gettransaction returning error

In the Peercoin 0.3.2 debug window when I say:

gettransaction d61e5b291c475765f8b99f9f7a915e730dedff1e9b5bcf4c57a5f04fc0c622ed

it tells me:

Invalid or non-wallet transaction id (code -5)

I’ve copied the transaction id from bkchain.org and it should be valid.

In addition to setting a username and password for RPC, My peercoin.conf file has the following lines in it:

listen=1
server=1
rpctimeout=30
txindex=1

second question: does txindex=1 do anything in Peercoin.conf? It does not seem to be one of the command line options for Peercoin0.3.2

Just checked your transaction in Bkchain.org: http://bkchain.org/ppc/search?search=d61e5b291c475765f8b99f9f7a915e730dedff1e9b5bcf4c57a5f04fc0c622ed

But it doesn’t seem to exist in there. Best to check your transaction code again. Possibly a copy/paste issue? Or is it really a Peercoin transaction?

Regarding your second question. I think you are hitting this problem as described here (and solution):

Hope that helps. Just keep in mind that Peercoin has inherited most of the Bitcoin code, so it’s likely that this will work for Peercoin. Haven’t tried myself as it requires reloading the blockchain and I’m still on an old fashioned datacap.

Thanks! I don’t know why I didn’t think to check them on bkchain.org

However, I’m having trouble now searching any transaction id’s on that site. The ones I copy from bkchain.org aren’t being found, and the “transaction id” I’m getting from my own wallet aren’t found there either.

I’m new to this. I must be doing something wrong!

There’s something wrong with bkchain.org tonight, when looking up transactions by ID.

Here’s the transaction you were looking for, from blockr.io:

http://ppc.blockr.io/tx/info/d61e5b291c475765f8b99f9f7a915e730dedff1e9b5bcf4c57a5f04fc0c622ed

That’s the coinbase transaction of a proof-of-stake reward, which is tied to this coinstake transaction:

http://ppc.blockr.io/tx/info/f01f917954542311947b0d18282dd89e42c5fd854288a3e767ac1328f6f3b5c8

Congratulations, someone created new peercoins :slight_smile:

Hmm, that’s a bit of a worry that searching doesn’t work properly on bkchain.org.

@ben, did you pm bkchain already?

So now that we’ve verified the transaction ID, why can’t I use “gettransaction” to search by transaction id? I’m running Fuzzybear’s Peercoin0.3.2 and I can only do “gettransaction” for transaction id’s from my own wallet.

Specifying txindex=1 in the conf file doesn’t seem to work (for bitcoin this is supposed to keep transaction id’s in the database, which is not done by default (?)).

I’ve also tried rebuilding the database with txindex=1 . Yes, I know txindex is not in the list of startup options for peercoind. There doesn’t seem to be anything similar.

I can only confirm the behaviour you are seeing in the debug window of the wallet.

Valid transactions are not recognised unless from my own wallet. Might have stumbled upon a little bug.
Will try to get @Fuzzybear 's attention as I understand not many users have upgraded to this wallet as it has been only successfully compiled for Windows.

Or as anyone else know the fix for this, please feel free.

No, this isn’t a bug.

gettransaction is a command limited to the transactions you’ve sent/received from your own wallet.

This works this way with Bitcoin’s wallet too.

Searching a transaction would take a huge amount of data, cpu, etc, if you were able to search every transaction ever made. Consider the fact that a blockchain has millions of transactions. Running a gettransaction command wouldn’t be that easy.

This is why block explorers take transactions they see on the network and save them to a database like MySQL for searching later.

Definitely not a bug.

Thanks for your quick reply Ppcman. Glad that this is expected behaviour. Thought it was weird. Saved me some strolling over the internetz.

Thanks ppcman! I feel a little dumb. I should have doubted my understanding of the whole thing and turned to the internets when I thought “if you can search transaction ids in your wallet database, then what are the block explorer websites for?”

Perhaps there is a hands on tutorial somewhere, or in the works, which will guide people to an understanding of the protocol through little experiments with the RPC like the one you’ve just guided me through? It could be popular… and useful not just to technical types.

I’m more fascinated with crypto than I’ve been with anything in a long time. Not just the technical parts. For instance with the concept that you can use distributed computing and mutual distrust to establish an accounting system that can replace the traditional methods, which seem to me to rely on blind trust backed by some kind of certification (accountants) and regulation (law). I know I’m not the first to say that if this can be proven to work it obviously has vast applications to all kinds of things (one might imagine unhackable software?) far beyond cryptocurrency.

So it looks like given a block hash I can use my wallet’s database to get all the data I need about its constituent transactions. There should be no reason I can’t use the same database to find a block hash given a txid.

SO: is there a function in the Peercoin RPC that will tell me which block a txid is found in? I’m feeling stupid again because I can’t find it.

if I say:
getblock 3be2ef6d4d0462ad34d805756222b7d93d5803a181072a4ec7e3d0c0d63299d5 true

I get:
{
[ …deleted stuff related to the block … ]

“tx” : [
“34de75c53e0fc643b05ac29413937c8d2ad3e75d0c48465239f1795e217dff1a base”,
“2014-03-06 09:46:16 UTC”,
" 0000000000000000000000000000000000000000000000000000000000000000 -1",
" out 0.00 “,
“cccc63490d8f0343f23867911a044d1f815c30c385da6fe0c48d1fdd0352bffb stake”,
“2014-03-06 09:46:16 UTC”,
" da381e14b5dd176afe1a39083ba58219cf4a3591b87e003d638711219a81b51d 1”,
" out 0.00 “,
" out 23568.74 03ab19f9a7 OP_CHECKSIG”,
" out 23568.75 03ab19f9a7 OP_CHECKSIG"
]
}

With listtransactions you can if you know the current height (e.g. from getmininginfo). Just deduct the number of confirmations from the current height and you have the block number of your transaction.

Not sure if this answers your question.

I got the same error in both 0.3.2 and 0.4.0 RC1. So how to get transaction details from a txid by RPC? Thanks.

bump

while doing research to finish my project, I’ve stumbled upon this blog http://upcoder.com/8/fast-blockchain-scanning/

in short, -txindex does not work, but getblock … false should give you a raw hex data which you can decypher the hard way, shoot each tx in the block to the decoderawtransaction function and presto the getransaction limitation is bypassed :-*

Are you sure -txindex doesn’t work?

After setting -txindex, it will not take effect UNTIL you ALSO run the client once with -reindex.

Once you did that (set txindex=1, and ran the client ONCE with reindex=1) you should be able to query any transaction and get its info like so:

rpc.decoderawtransaction(rpc.getrawtransaction(tx_id))

That block you posted looks legit though, I’ve also seen that but haven’t tried it yet. Let me know if you have any success.

emeth,

thanks for your help. -reindex did help. There was no progress tho when it finished but getrawtransaction works!

However, getblock … false did not return a raw hex value. But that s okay as getrawtransaction works just as fine.

I think I ve got every part in place to fill the database with what I need for my project.

cu