mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
tools: Use ECC_Context helper in bitcoin-tx and bitcoin-wallet tools
This commit is contained in:
@@ -692,21 +692,10 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
|
|||||||
tx = mergedTx;
|
tx = mergedTx;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Secp256k1Init
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Secp256k1Init() {
|
|
||||||
ECC_Start();
|
|
||||||
}
|
|
||||||
~Secp256k1Init() {
|
|
||||||
ECC_Stop();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static void MutateTx(CMutableTransaction& tx, const std::string& command,
|
static void MutateTx(CMutableTransaction& tx, const std::string& command,
|
||||||
const std::string& commandVal)
|
const std::string& commandVal)
|
||||||
{
|
{
|
||||||
std::unique_ptr<Secp256k1Init> ecc;
|
std::unique_ptr<ECC_Context> ecc;
|
||||||
|
|
||||||
if (command == "nversion")
|
if (command == "nversion")
|
||||||
MutateTxVersion(tx, commandVal);
|
MutateTxVersion(tx, commandVal);
|
||||||
@@ -726,10 +715,10 @@ static void MutateTx(CMutableTransaction& tx, const std::string& command,
|
|||||||
else if (command == "outaddr")
|
else if (command == "outaddr")
|
||||||
MutateTxAddOutAddr(tx, commandVal);
|
MutateTxAddOutAddr(tx, commandVal);
|
||||||
else if (command == "outpubkey") {
|
else if (command == "outpubkey") {
|
||||||
ecc.reset(new Secp256k1Init());
|
ecc.reset(new ECC_Context());
|
||||||
MutateTxAddOutPubKey(tx, commandVal);
|
MutateTxAddOutPubKey(tx, commandVal);
|
||||||
} else if (command == "outmultisig") {
|
} else if (command == "outmultisig") {
|
||||||
ecc.reset(new Secp256k1Init());
|
ecc.reset(new ECC_Context());
|
||||||
MutateTxAddOutMultiSig(tx, commandVal);
|
MutateTxAddOutMultiSig(tx, commandVal);
|
||||||
} else if (command == "outscript")
|
} else if (command == "outscript")
|
||||||
MutateTxAddOutScript(tx, commandVal);
|
MutateTxAddOutScript(tx, commandVal);
|
||||||
@@ -737,7 +726,7 @@ static void MutateTx(CMutableTransaction& tx, const std::string& command,
|
|||||||
MutateTxAddOutData(tx, commandVal);
|
MutateTxAddOutData(tx, commandVal);
|
||||||
|
|
||||||
else if (command == "sign") {
|
else if (command == "sign") {
|
||||||
ecc.reset(new Secp256k1Init());
|
ecc.reset(new ECC_Context());
|
||||||
MutateTxSign(tx, commandVal);
|
MutateTxSign(tx, commandVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,10 +128,9 @@ MAIN_FUNCTION
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ECC_Start();
|
ECC_Context ecc_context{};
|
||||||
if (!wallet::WalletTool::ExecuteWalletToolFunc(args, command->command)) {
|
if (!wallet::WalletTool::ExecuteWalletToolFunc(args, command->command)) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
ECC_Stop();
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user