Title: regex for bitcointransaction string Post by: kangarooz on May 26, 2014, 12:50:13 PM 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; Title: Re: regex for bitcointransaction string Post by: grue on May 26, 2014, 04:34:24 PM Is there any RegEx for checking if a string could be a valid bitcointransaction? string as in what? the transaction id?Title: Re: regex for bitcointransaction string Post by: kangarooz on May 26, 2014, 05:47:31 PM I got a string containing the "txid" which should be checked.
All the best; Title: Re: regex for bitcointransaction string Post by: grue on May 26, 2014, 07:04:34 PM I got a string containing the "txid" which should be checked. 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.All the best; Title: Re: regex for bitcointransaction string Post by: telepatheic on May 26, 2014, 08:38:29 PM I got a string containing the "txid" which should be checked. 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.All the best; 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 Title: Re: regex for bitcointransaction string Post by: grue on May 26, 2014, 11:23:48 PM anyways, the best solution is to use getrawtransaction, which allows you to retrieve any transaction.
Title: Re: regex for bitcointransaction string Post by: fbueller on May 28, 2014, 09:10:20 PM 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); Title: Re: regex for bitcointransaction string Post by: grue on May 28, 2014, 10:35:11 PM 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. that's weird. because it works fine on my bitcoin core instance, and it doesn't have txindex enabled.To get confirmations for the transaction, as well as the raw and decoded tx, you can use getrawtransaction(txid, 1); |