Skip to content

Commit 1a27e46

Browse files
committed
respect former api
1 parent a4798e6 commit 1a27e46

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/bitcoin-tx.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ static bool AppInitRawTx(int argc, char* argv[])
6464
strUsage += HelpMessageOpt("-create", _("Create new, empty TX."));
6565
strUsage += HelpMessageOpt("-json", _("Select JSON output"));
6666
strUsage += HelpMessageOpt("-txid", _("Output only the hex-encoded transaction id of the resultant transaction."));
67-
strUsage += HelpMessageOpt("-segwit", _("Produce a segwit output."));
68-
strUsage += HelpMessageOpt("-p2sh", _("Wrap output into P2SH."));
6967
AppendParamsHelpMessages(strUsage);
7068

7169
fprintf(stdout, "%s", strUsage.c_str());
@@ -78,7 +76,9 @@ static bool AppInitRawTx(int argc, char* argv[])
7876
strUsage += HelpMessageOpt("nversion=N", _("Set TX version to N"));
7977
strUsage += HelpMessageOpt("outaddr=VALUE:ADDRESS", _("Add address-based output to TX"));
8078
strUsage += HelpMessageOpt("outdata=[VALUE:]DATA", _("Add data-based output to TX"));
81-
strUsage += HelpMessageOpt("outscript=VALUE:SCRIPT", _("Add raw script output to TX"));
79+
strUsage += HelpMessageOpt("outscript=VALUE:SCRIPT(:\"SEGWIT\")(:\"P2SH\")", _("Add raw script output to TX") + ". " +
80+
_("Optionally add the \"SEGWIT\" flag to produce a segwit output") + ". " +
81+
_("Optionally add the \"P2SH\" flag to wrap the script in a P2SH output."));
8282
strUsage += HelpMessageOpt("sign=SIGHASH-FLAGS", _("Add zero or more signatures to transaction") + ". " +
8383
_("This command requires JSON registers:") +
8484
_("prevtxs=JSON object") + ", " +
@@ -275,26 +275,26 @@ static void MutateTxAddOutData(CMutableTransaction& tx, const string& strInput)
275275

276276
static void MutateTxAddOutScript(CMutableTransaction& tx, const string& strInput)
277277
{
278-
// separate VALUE:SCRIPT in string
279-
size_t pos = strInput.find(':');
280-
if ((pos == string::npos) ||
281-
(pos == 0))
278+
// separate VALUE:SCRIPT(:SEGWIT)(:P2SH)
279+
std::vector<std::string> vStrInput;
280+
boost::split(vStrInput, strInput, boost::is_any_of(":"));
281+
if (vStrInput.size() < 2)
282282
throw runtime_error("TX output missing separator");
283283

284284
// extract and validate VALUE
285-
string strValue = strInput.substr(0, pos);
285+
string strValue = vStrInput[0];
286286
CAmount value;
287287
if (!ParseMoney(strValue, value))
288288
throw runtime_error("invalid TX output value");
289289

290290
// extract and validate script
291-
string strScript = strInput.substr(pos + 1, string::npos);
291+
string strScript = vStrInput[1];
292292
CScript scriptPubKey = ParseScript(strScript); // throws on err
293293

294-
if (GetBoolArg("-segwit", false)) {
294+
if (std::find(vStrInput.begin(), vStrInput.end(), "SEGWIT") != vStrInput.end()) {
295295
scriptPubKey = GetScriptForWitness(scriptPubKey);
296296
}
297-
if (GetBoolArg("-p2sh", false)) {
297+
if (std::find(vStrInput.begin(), vStrInput.end(), "P2SH") != vStrInput.end()) {
298298
CBitcoinAddress addr(scriptPubKey);
299299
scriptPubKey = GetScriptForDestination(addr.Get());
300300
}

0 commit comments

Comments
 (0)