Today I used the pushtx page of just-dice to push a raw transaction, I got the message "OK", but it would be nice to have a transaction ID to go along with that. This is just my request/suggestion in regards this page:
https://just-dice.com/pushtxIf there's another pushtx page elsewhere that can push txs in hex format into the clam network and which gives you back the txid, that'd be great.
Oh, and I guess I can just hash my transaction to get my transaction id? Is that correct? Do I use sha256sum or something like that?
I've added the txid to the output. You'll see it when I push the next update to the site.
I thought you could just sha256 hash the tx to get its txid, but it doesn't work:
$ clamd getrawtransaction 2b90afc1a9b8a82c187aa59dfb5ea1767bc1976fcd9696ef4dda0886ca6771d7 | xxd -r -p | sha256sum
e2410f88b750f1a90c316fdcc6d1bb08e8abafd5ab9f0b34682101c662a6266f -
I don't know why. I tried reversing the bytes, but that doesn't fix it.
getrawtransaction gets its hex string like this:
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << tx;
string strHex = HexStr(ssTx.begin(), ssTx.end());
txid's are calculated like this:
uint256 GetHash() const
{
return SerializeHash(*this);
}
I would expect them to both end up using the serialization code:
IMPLEMENT_SERIALIZE
(
READWRITE(this->nVersion);
nVersion = this->nVersion;
READWRITE(nTime);
READWRITE(vin);
READWRITE(vout);
READWRITE(nLockTime);
if (this->nVersion > LEGACY_VERSION_1)
{
READWRITE(strCLAMSpeech);
}
)
but somehow they get different results. So I don't know.
Edit: I didn't figure out why it doesn't work - it's presumably something to do with the different way that SER_GETHASH and SER_NETWORK serialize transactions - but I did work out an easy way of getting your txid from the hex string. Just "decoderawtransaction" on it, and look at the 2nd line:
$ clamd decoderawtransaction $(clamd getrawtransaction 2b90afc1a9b8a82c187aa59dfb5ea1767bc1976fcd9696ef4dda0886ca6771d7) | head -2
{
"txid": "2b90afc1a9b8a82c187aa59dfb5ea1767bc1976fcd9696ef4dda0886ca6771d7",