Author

Topic: regex for bitcointransaction string (Read 812 times)

legendary
Activity: 2058
Merit: 1452
May 28, 2014, 05:35:11 PM
#8
Only if your bitcoin.conf has txindex=1 in it. And you've reindexed by running: ./bitcoind -reindex. That will let you run getrawtransaction() on any txid.

To get confirmations for the transaction, as well as the raw and decoded tx, you can use getrawtransaction(txid, 1);
that's weird. because it works fine on my bitcoin core instance, and it doesn't have txindex enabled.
sr. member
Activity: 412
Merit: 287
May 28, 2014, 04:10:20 PM
#7
anyways, the best solution is to use getrawtransaction, which allows you to retrieve any transaction.

Only if your bitcoin.conf has txindex=1 in it. And you've reindexed by running: ./bitcoind -reindex. That will let you run getrawtransaction() on any txid.

To get confirmations for the transaction, as well as the raw and decoded tx, you can use getrawtransaction(txid, 1);
legendary
Activity: 2058
Merit: 1452
May 26, 2014, 06:23:48 PM
#6
anyways, the best solution is to use getrawtransaction, which allows you to retrieve any transaction.
jr. member
Activity: 56
Merit: 1
May 26, 2014, 03:38:29 PM
#5
I got a string containing the "txid" which should be checked.

All the best;
the txid is the sha-1 hash of a transaction. you can't use the txid to determine whether a transaction is valid, because any 64 digit hexadecimal number can be a txid.

It's not the SHA-1 it is the SHA256d. Also quite confusingly, the output bytes are reversed when displayed to the user!

The RegEx you are looking for is:

Code:
/^[0-9a-f]{64}$/i 
legendary
Activity: 2058
Merit: 1452
May 26, 2014, 02:04:34 PM
#4
I got a string containing the "txid" which should be checked.

All the best;
the txid is the sha-1 hash of a transaction. you can't use the txid to determine whether a transaction is valid, because any 64 digit hexadecimal number can be a txid.
newbie
Activity: 4
Merit: 0
May 26, 2014, 12:47:31 PM
#3
I got a string containing the "txid" which should be checked.

All the best;
legendary
Activity: 2058
Merit: 1452
May 26, 2014, 11:34:24 AM
#2
Is there any RegEx for checking if a string could be a valid bitcointransaction?
string as in what? the transaction id?
newbie
Activity: 4
Merit: 0
May 26, 2014, 07:50:13 AM
#1
Dear guys;

Is there any RegEx for checking if a string could be a valid bitcointransaction?
A currently use gettransaction() to check the confirmations of the transaction, as you may know gettransaction() only accepts txids made by the wallet of the bitcoind running this command, so I want to check the entered txid before, to catch as many faults as I can.
Programming language: Python

All the best;
Jump to: