False. TX fee gets bigger as the size of the TX grows. Miner would simply not confirm a TX that does not pay a high enough fee.
Correct.
Here’s the Lua function I use to construct a raw transaction:
function bitcoin_fun_create_raw_transaction(inputs, outputs)
-- Because Lua dictionaries cannot have a predefined order we must
-- construct this request manually.
local outputlist = "{";
local k, v;
local mapping = {};
local order = {};
local index;
local index_hex;
local hex;
local salt = "MPGdJA7KX9TwBB7i";
for i=1, #outputs do
k, v = next(outputs[i], nil);
index_hex = hash_SHA256(i..salt, false);
index_hex = string.sub(index_hex, 1, 40);
index = string.fromhex(index_hex);
index = Bitcoin.stringToAddress(index);
hex = Bitcoin.addressToString(k);
hex = string.tohex(hex);
mapping[index_hex] = hex;
table.insert(order, index_hex);
--log("mapping["..index_hex.."] = "..hex);
outputlist = outputlist..'"'..index..'": '..v;
if (i < #outputs) then
outputlist = outputlist .. ", ";
end;
end;
outputlist = outputlist .. "}";
local inputlist = JSON:encode(inputs);
local request = '{\n'..
' "id": 1, \n'..
' "jsonrpc": "2.0", \n'..
' "method": "createrawtransaction", \n'..
' "params": [ '..inputlist..', '..outputlist..' ]\n'..
'}';
--warn(request);
response = url_post("http://"..bitcoin.rpc_user..":"
..bitcoin.rpc_password.."@"
..bitcoin.rpc_ip..":"
..bitcoin.rpc_port.."/", request, bitcoin.curl_timeout);
--warn(response);
if (response ~= nil) then
local t = JSON:decode(response);
if (t ~= nil and type(t) == "table") then
if (type(t.error) == "table" and type(t.error.message) == "string" ) then
log("Bitcoin createrawtransaction: "..t.error.message);
notify_admin("createrawtransaction", t.error.message);
else
local k,v;
local s = 1;
local e;
local bad = nil;
-- Replace indexes with real output hex representations that may
-- contain duplicates.
for i=1, #order do
k = order[i];
v = mapping[k];
s, e = string.find(t.result, k, s, true);
if (s ~= nil and e ~= nil) then
t.result = t.result:sub(1, s-1) .. v .. t.result:sub(e+1);
s = e + 1;
else
bad = k;
end;
end;
--warn(t.result);
if (bad ~= nil) then
local msg = "Index hex "..bad.." not found from raw transaction.";
warn(msg);
notify_admin("createrawtransaction", msg);
return nil;
end;
end;
return t.result;
end;
else
local msg = "Bitcoin RPC failed on cURL post: createrawtransaction";
warn(msg);
notify_admin("createrawtransaction", msg);
end;
notify_admin("createrawtransaction", "Failed to create a raw transaction, returning nil.");
return nil;
end
It doesn’t do anything about OP_RETURNs though and you would have to do the change address manually. If you don’t include a change address you could lose a lot of (bit)coins!