Closed grctest closed 7 years ago
Unable to create an op_return transaction without data support in createrawtransaction (3.5.6.1a).
Looking into this now.
After the next release when you test this take a look at script.cpp line 1511. Ppcoin returns a 1 for nulldata while bitcoin returns a -1. I coded this as a -1. The only other questionable issue is sending rawdata to an invalid address (bitcoin appears to support this). I merged that feature in; so that will also need tested.
Production node:
gridcoinresearchd createrawtransaction '[{"txid":"bfc7ab3793680ef73e45b2c0ed1b8091eeb21f89ae7bc7f7cf3262cc90214c29","vout":0}]' '{"S2YKdCFvTAWKLgwsFQCJDSMNPbw1a5HJB4":0.2, "data":"00010203"}'
error: {"code":-8,"message":"Data must be hexadecimal string (not '')"}
Testnet node:
gridcoinresearchd createrawtransaction '[{"txid":"fff30a59f89acc91a1d8e21f075d1b571d812336a71b086cd92b461c6214b845","vout":1}]' '{"data":"4752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e54"}'
error: {"code":-8,"message":"Data must be hexadecimal string (not '')"}
Edit: Section of code in createrawtransaction where the hex encoded data is sent to the "ParseHexV" function:
std::vector<unsigned char> data = ParseHexV(params[1],"Data");
Unclear where params[1] comes from, but if either "params[1].type();" is not == str_type or "params[1].get_str();" is blank, then it'll throw the error.
ParseHexV called from createrawtransaction, for some reason strHex is returned as blank?
vector<unsigned char> ParseHexV(const Value& v, string strName)
{
string strHex;
if (v.type() == str_type)
strHex = v.get_str();
if (!IsHex(strHex))
throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')");
return ParseHex(strHex);
}
Uneducated guesses:
createrawtransaction converted to an array with 'params[0]':
if (strMethod == "createrawtransaction" && n > 0) ConvertTo<Array>(params[0]);
https://github.com/gridcoin/Gridcoin-Research/blob/cea4b9610655f8df02f4bde434de8140f9e37e02/src/bitcoinrpc.cpp#L1245
createrawtransaction refers to the array with 'params[0]'
extern json_spirit::Value createrawtransaction(const json_spirit::Array& params, bool fHelp);
https://github.com/gridcoin/Gridcoin-Research/blob/cea4b9610655f8df02f4bde434de8140f9e37e02/src/bitcoinrpc.h#L211
But the following uses 'params[1]' ?
std::vector<unsigned char> data = ParseHexV(params[1],"Data");
Oh great :)
I was able to get the command working but had to make a code change. Im still not sure if the entire process will work, but hopefully this will be a step in the right direction. Go ahead and grab 3.5.6.3-leisure and you should be able to issue the command now.
Excellent, it works! (Testnet)
gridcoinresearchd createrawtransaction '[{"txid":"fff30a59f89acc91a1d8e21f075d1b571d812336a71b086cd92b461c6214b845","vout":1}]' '{"data":"4752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e54"}'
01000000d4d61b570145b814621c462bd96c081ba73623811d571b5d071fe2d8a191cc9af8590af3ff0100000000ffffffff010000000000000000276a254752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e540000000000
gridcoinresearchd signrawtransaction 01000000d4d61b570145b814621c462bd96c081ba73623811d571b5d071fe2d8a191cc9af8590af3ff0100000000ffffffff010000000000000000276a254752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e540000000000
{
"hex" : "01000000d4d61b570145b814621c462bd96c081ba73623811d571b5d071fe2d8a191cc9af8590af3ff0100000048473044022037485bbc12d59fa5dca3943e6f9961898ff3719dcc27d705334d6d5b42e0186d0220616f2300187fa8cd32575cf0eb0616e69e3eb76c5fdb374a4f191b7be6dd138c01ffffffff010000000000000000276a254752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e540000000000",
"complete" : true
}
gridcoinresearchd sendrawtransaction 01000000d4d61b570145b814621c462bd96c081ba73623811d571b5d071fe2d8a191cc9af8590af3ff0100000048473044022037485bbc12d59fa5dca3943e6f9961898ff3719dcc27d705334d6d5b42e0186d0220616f2300187fa8cd32575cf0eb0616e69e3eb76c5fdb374a4f191b7be6dd138c01ffffffff010000000000000000276a254752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e540000000000
31709dd630170aeec6b88db2475cbad2845c714b926f080468f455ecdad142cd
gridcoinresearchd gettransaction 31709dd630170aeec6b88db2475cbad2845c714b926f080468f455ecdad142cd
{
"txid" : "31709dd630170aeec6b88db2475cbad2845c714b926f080468f455ecdad142cd",
"version" : 1,
"time" : 1461442260,
"locktime" : 0,
"hashboinc" : "",
"vin" : [
{
"txid" : "fff30a59f89acc91a1d8e21f075d1b571d812336a71b086cd92b461c6214b845",
"vout" : 1,
"scriptSig" : {
"asm" : "3044022037485bbc12d59fa5dca3943e6f9961898ff3719dcc27d705334d6d5b42e0186d0220616f2300187fa8cd32575cf0eb0616e69e3eb76c5fdb374a4f191b7be6dd138c01",
"hex" : "473044022037485bbc12d59fa5dca3943e6f9961898ff3719dcc27d705334d6d5b42e0186d0220616f2300187fa8cd32575cf0eb0616e69e3eb76c5fdb374a4f191b7be6dd138c01"
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 0.00000000,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_RETURN 4752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e54",
"type" : "nulldata"
}
}
],
"amount" : 0.00000000,
"fee" : -73.60565618,
"confirmations" : 6,
"blockhash" : "a9bffd8d497ed9fa93e52859a246d9e1921caeb953bc36a8fcb5c6e6cf86c885",
"blockindex" : 2,
"blocktime" : 1461442752,
"txid" : "31709dd630170aeec6b88db2475cbad2845c714b926f080468f455ecdad142cd",
"time" : 1461442616,
"timereceived" : 1461442616,
"details" : [
{
"account" : "",
"address?" : "1Wh4bh",
"category" : "send",
"amount" : 0.00000000,
"fee" : -73.60565618
}
]
}
2nd try with a normal transaction + data transaction:
gridcoinresearchd createrawtransaction '[{"txid":"00039281263dbbb13d779a3959646c2ac60bce957e9493de0cb7ebe374eb6380","vout":1}]' '{"mj2tqUAbZa8c8nHEVjCUK7QJ8KNFbfDbJA":1, "data":"4752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e54"}'
01000000f1ea1b57018063eb74e3ebb70cde93947e95ce0bc62a6c6459399a773db1bb3d26819203000100000000ffffffff0200e1f505000000001976a9142691f824d6cbbb4fe38b95c60c3144e30911649c88ac0000000000000000276a254752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e540000000000
gridcoinresearchd signrawtransaction 01000000f1ea1b57018063eb74e3ebb70cde93947e95ce0bc62a6c6459399a773db1bb3d26819203000100000000ffffffff0200e1f505000000001976a9142691f824d6cbbb4fe38b95c60c3144e30911649c88ac0000000000000000276a254752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e540000000000
{
"hex" : "01000000f1ea1b57018063eb74e3ebb70cde93947e95ce0bc62a6c6459399a773db1bb3d26819203000100000049483045022100d43cdf5efc14f088830993b958e9c4394e65c789f22a1edd84afda61ea720cf402200ecfc80fb6ca4fe416d141563d639d363fcb1bdfb509568a5948c4c760a34ee301ffffffff0200e1f505000000001976a9142691f824d6cbbb4fe38b95c60c3144e30911649c88ac0000000000000000276a254752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e540000000000",
"complete" : true
}
gridcoinresearchd sendrawtransaction 01000000f1ea1b57018063eb74e3ebb70cde93947e95ce0bc62a6c6459399a773db1bb3d26819203000100000049483045022100d43cdf5efc14f088830993b958e9c4394e65c789f22a1edd84afda61ea720cf402200ecfc80fb6ca4fe416d141563d639d363fcb1bdfb509568a5948c4c760a34ee301ffffffff0200e1f505000000001976a9142691f824d6cbbb4fe38b95c60c3144e30911649c88ac0000000000000000276a254752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e540000000000
ae76255493439411356e37e1d2357359355b2d2b33a37eb51ec03d3c3b38b84f
gridcoinresearchd gettransaction ae76255493439411356e37e1d2357359355b2d2b33a37eb51ec03d3c3b38b84f
{
"txid" : "ae76255493439411356e37e1d2357359355b2d2b33a37eb51ec03d3c3b38b84f",
"version" : 1,
"time" : 1461447409,
"locktime" : 0,
"hashboinc" : "",
"vin" : [
{
"txid" : "00039281263dbbb13d779a3959646c2ac60bce957e9493de0cb7ebe374eb6380",
"vout" : 1,
"scriptSig" : {
"asm" : "3045022100d43cdf5efc14f088830993b958e9c4394e65c789f22a1edd84afda61ea720cf402200ecfc80fb6ca4fe416d141563d639d363fcb1bdfb509568a5948c4c760a34ee301",
"hex" : "483045022100d43cdf5efc14f088830993b958e9c4394e65c789f22a1edd84afda61ea720cf402200ecfc80fb6ca4fe416d141563d639d363fcb1bdfb509568a5948c4c760a34ee301"
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 1.00000000,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 2691f824d6cbbb4fe38b95c60c3144e30911649c OP_EQUALVERIFY OP_CHECKSIG",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"mj2tqUAbZa8c8nHEVjCUK7QJ8KNFbfDbJA"
]
}
},
{
"value" : 0.00000000,
"n" : 1,
"scriptPubKey" : {
"asm" : "OP_RETURN 4752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e54",
"type" : "nulldata"
}
}
],
"amount" : 0.00000000,
"fee" : -195.31209651,
"confirmations" : 1,
"blockhash" : "205789a58e9ac4f32eecfd4e0572f009e7cb3a3cd6d36b1d232540be11c94f3a",
"blockindex" : 2,
"blocktime" : 1461447568,
"txid" : "ae76255493439411356e37e1d2357359355b2d2b33a37eb51ec03d3c3b38b84f",
"time" : 1461447478,
"timereceived" : 1461447478,
"details" : [
{
"account" : "",
"address" : "mj2tqUAbZa8c8nHEVjCUK7QJ8KNFbfDbJA",
"category" : "send",
"amount" : -1.00000000,
"fee" : -195.31209651
},
{
"account" : "",
"address?" : "1Wh4bh",
"category" : "send",
"amount" : 0.00000000,
"fee" : -195.31209651
},
{
"account" : "",
"address" : "mj2tqUAbZa8c8nHEVjCUK7QJ8KNFbfDbJA",
"category" : "receive",
"amount" : 1.00000000
}
]
}
gridcoinresearchd getrawtransaction ae76255493439411356e37e1d2357359355b2d2b33a37eb51ec03d3c3b38b84f 1
{
"hex" : "01000000f1ea1b57018063eb74e3ebb70cde93947e95ce0bc62a6c6459399a773db1bb3d26819203000100000049483045022100d43cdf5efc14f088830993b958e9c4394e65c789f22a1edd84afda61ea720cf402200ecfc80fb6ca4fe416d141563d639d363fcb1bdfb509568a5948c4c760a34ee301ffffffff0200e1f505000000001976a9142691f824d6cbbb4fe38b95c60c3144e30911649c88ac0000000000000000276a254752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e540000000000",
"txid" : "ae76255493439411356e37e1d2357359355b2d2b33a37eb51ec03d3c3b38b84f",
"version" : 1,
"time" : 1461447409,
"locktime" : 0,
"hashboinc" : "",
"vin" : [
{
"txid" : "00039281263dbbb13d779a3959646c2ac60bce957e9493de0cb7ebe374eb6380",
"vout" : 1,
"scriptSig" : {
"asm" : "3045022100d43cdf5efc14f088830993b958e9c4394e65c789f22a1edd84afda61ea720cf402200ecfc80fb6ca4fe416d141563d639d363fcb1bdfb509568a5948c4c760a34ee301",
"hex" : "483045022100d43cdf5efc14f088830993b958e9c4394e65c789f22a1edd84afda61ea720cf402200ecfc80fb6ca4fe416d141563d639d363fcb1bdfb509568a5948c4c760a34ee301"
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 1.00000000,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 2691f824d6cbbb4fe38b95c60c3144e30911649c OP_EQUALVERIFY OP_CHECKSIG",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"mj2tqUAbZa8c8nHEVjCUK7QJ8KNFbfDbJA"
]
}
},
{
"value" : 0.00000000,
"n" : 1,
"scriptPubKey" : {
"asm" : "OP_RETURN 4752432d5241494e3a20414c5445524e415449564520414444524553532f4143434f554e54",
"type" : "nulldata"
}
}
],
"blockhash" : "205789a58e9ac4f32eecfd4e0572f009e7cb3a3cd6d36b1d232540be11c94f3a",
"confirmations" : 15,
"time" : 1461447568,
"blocktime" : 1461447568
}
3rd try, this time sending testnet coins to an address. It looks like creating a raw transaction with both 5 GRC being sent to an address alongside an op_return data transaction does not burn the 5 GRC, so in order to burn the 5 GRC it'll need to be sent to a burn address generated within the client.
gridcoinresearchd createrawtransaction '[{"txid":"55432efddbfc75c4836c8ca5656082be897a0e5061cf567f4e3f3ace5d6459c8","vout":1}]' '{"mhHBjP4KkXB1hgAHcVFpqYyBAtiEcbW9mP":5,"data":"4254533a4163636f756e74"}'
0100000044d41c5701c859645dce3a3f4e7f56cf61500e7a89be826065a58c6c83c475fcdbfd2e43550100000000ffffffff020065cd1d000000001976a9141355a4fc30fe9ff2049c49e9b5caa9ff58fce5ff88ac00000000000000000d6a0b4254533a4163636f756e740000000000
gridcoinresearchd signrawtransaction 0100000044d41c5701c859645dce3a3f4e7f56cf61500e7a89be826065a58c6c83c475fcdbfd2e43550100000000ffffffff020065cd1d000000001976a9141355a4fc30fe9ff2049c49e9b5caa9ff58fce5ff88ac00000000000000000d6a0b4254533a4163636f756e740000000000
{
"hex" : "0100000044d41c5701c859645dce3a3f4e7f56cf61500e7a89be826065a58c6c83c475fcdbfd2e4355010000004847304402200fa3546f9912d87aa8a0999cffd005004d3821bc7988cbd04238e7bdedd9f180022056b0eb88bc29729edb5f0cfb65e262e7bdb22c8b5fe38d4365d93c8408b0506f01ffffffff020065cd1d000000001976a9141355a4fc30fe9ff2049c49e9b5caa9ff58fce5ff88ac00000000000000000d6a0b4254533a4163636f756e740000000000",
"complete" : true
}
gridcoinresearchd sendrawtransaction 0100000044d41c5701c859645dce3a3f4e7f56cf61500e7a89be826065a58c6c83c475fcdbfd2e4355010000004847304402200fa3546f9912d87aa8a0999cffd005004d3821bc7988cbd04238e7bdedd9f180022056b0eb88bc29729edb5f0cfb65e262e7bdb22c8b5fe38d4365d93c8408b0506f01ffffffff020065cd1d000000001976a9141355a4fc30fe9ff2049c49e9b5caa9ff58fce5ff88ac00000000000000000d6a0b4254533a4163636f756e740000000000

gettransaction
968ee0345858452f97454f1133074a128ee969ebece81f11ef20c36928685a79

{
"txid" : "968ee0345858452f97454f1133074a128ee969ebece81f11ef20c36928685a79",
"version" : 1,
"time" : 1461507140,
"locktime" : 0,
"hashboinc" : "",
"vin" : [
{
"txid" : "55432efddbfc75c4836c8ca5656082be897a0e5061cf567f4e3f3ace5d6459c8",
"vout" : 1,
"scriptSig" : {
"asm" : "304402200fa3546f9912d87aa8a0999cffd005004d3821bc7988cbd04238e7bdedd9f180022056b0eb88bc29729edb5f0cfb65e262e7bdb22c8b5fe38d4365d93c8408b0506f01",
"hex" : "47304402200fa3546f9912d87aa8a0999cffd005004d3821bc7988cbd04238e7bdedd9f180022056b0eb88bc29729edb5f0cfb65e262e7bdb22c8b5fe38d4365d93c8408b0506f01"
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 5.00000000,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 1355a4fc30fe9ff2049c49e9b5caa9ff58fce5ff OP_EQUALVERIFY OP_CHECKSIG",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"mhHBjP4KkXB1hgAHcVFpqYyBAtiEcbW9mP"
]
}
},
{
"value" : 0.00000000,
"n" : 1,
"scriptPubKey" : {
"asm" : "OP_RETURN 4254533a4163636f756e74",
"type" : "nulldata"
}
}
],
"amount" : 5.00000000,
"confirmations" : 1,
"blockhash" : "408a46f40050d1a40a63014d1b941a128c5a30ef56d5409da8115d04dfdb70a9",
"blockindex" : 2,
"blocktime" : 1461507328,
"txid" : "968ee0345858452f97454f1133074a128ee969ebece81f11ef20c36928685a79",
"time" : 1461507182,
"timereceived" : 1461507182,
"details" : [
{
"account" : "burn test",
"address" : "mhHBjP4KkXB1hgAHcVFpqYyBAtiEcbW9mP",
"category" : "receive",
"amount" : 5.00000000
}
]
}
getrawtransaction 968ee0345858452f97454f1133074a128ee969ebece81f11ef20c36928685a79 1

{
"hex" : "0100000044d41c5701c859645dce3a3f4e7f56cf61500e7a89be826065a58c6c83c475fcdbfd2e4355010000004847304402200fa3546f9912d87aa8a0999cffd005004d3821bc7988cbd04238e7bdedd9f180022056b0eb88bc29729edb5f0cfb65e262e7bdb22c8b5fe38d4365d93c8408b0506f01ffffffff020065cd1d000000001976a9141355a4fc30fe9ff2049c49e9b5caa9ff58fce5ff88ac00000000000000000d6a0b4254533a4163636f756e740000000000",
"txid" : "968ee0345858452f97454f1133074a128ee969ebece81f11ef20c36928685a79",
"version" : 1,
"time" : 1461507140,
"locktime" : 0,
"hashboinc" : "",
"vin" : [
{
"txid" : "55432efddbfc75c4836c8ca5656082be897a0e5061cf567f4e3f3ace5d6459c8",
"vout" : 1,
"scriptSig" : {
"asm" : "304402200fa3546f9912d87aa8a0999cffd005004d3821bc7988cbd04238e7bdedd9f180022056b0eb88bc29729edb5f0cfb65e262e7bdb22c8b5fe38d4365d93c8408b0506f01",
"hex" : "47304402200fa3546f9912d87aa8a0999cffd005004d3821bc7988cbd04238e7bdedd9f180022056b0eb88bc29729edb5f0cfb65e262e7bdb22c8b5fe38d4365d93c8408b0506f01"
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 5.00000000,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 1355a4fc30fe9ff2049c49e9b5caa9ff58fce5ff OP_EQUALVERIFY OP_CHECKSIG",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"mhHBjP4KkXB1hgAHcVFpqYyBAtiEcbW9mP"
]
}
},
{
"value" : 0.00000000,
"n" : 1,
"scriptPubKey" : {
"asm" : "OP_RETURN 4254533a4163636f756e74",
"type" : "nulldata"
}
}
],
"blockhash" : "408a46f40050d1a40a63014d1b941a128c5a30ef56d5409da8115d04dfdb70a9",
"confirmations" : 2,
"time" : 1461507328,
"blocktime" : 1461507328
}
I've started this page for instructing users how to send custom beacons on the Gridcoin blockchain: https://grcnode.co.uk/beacon.html
Forum thread: https://cryptocointalk.com/topic/44611-monitoring-selfburn-addresses-for-custom-beacons/?p=208479
The issue lies in "Step 2: Create the raw transaction." - the following command is accepted by the client, but the output transaction does not include OP_Return/hex encoded data:
gridcoinresearchd createrawtransaction [{"txid":txid,"vout":n,"data":"<Hex encoded data>"},...] {address:amount,...}
The createrawtransaction command is documented as:
gridcoinresearchd createrawtransaction [{"txid":txid,"vout":n},...] {"data":"<Hex encoded data>", address:amount,...}
But the above does not work, it returns an error stating that the hex encoded data isn't a valid address.Looks like the createrawtransaction command requires 'data' support: https://github.com/bitcoin/bitcoin/commit/627468d2ea1f4d5dea9561fe77aaf53f3a83b4d2 https://github.com/bitcoin/bitcoin/commit/d7078533ebd32bb5071f4dba8e3d9c5a3b1f0d4c https://github.com/bitcoin/bitcoin/pull/3128 https://github.com/bitcoin/bitcoin/commit/005609539b2184a474ffe9ebfe883984c900a3fb
With the data support, we can easily add OP_Return hex encoded data to transactions & extend the project rain feature to any external cryptocurrency system (side chains).
Edit: Peercoin inherited the following relevant commits: https://github.com/ppcoin/ppcoin/commit/1df628cb2789067da32d37926aceadaad76aeb03 https://github.com/ppcoin/ppcoin/commit/ac8be966243525c21ffd071dc23bcab01f4c33d4