Skip to content

Commit a08d2b3

Browse files
ryanofskyTheCharlatan
authored andcommitted
tools: Use ECC_Context helper in bitcoin-tx and bitcoin-wallet tools
1 parent 28905c1 commit a08d2b3

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

src/bitcoin-tx.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -692,21 +692,10 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
692692
tx = mergedTx;
693693
}
694694

695-
class Secp256k1Init
696-
{
697-
public:
698-
Secp256k1Init() {
699-
ECC_Start();
700-
}
701-
~Secp256k1Init() {
702-
ECC_Stop();
703-
}
704-
};
705-
706695
static void MutateTx(CMutableTransaction& tx, const std::string& command,
707696
const std::string& commandVal)
708697
{
709-
std::unique_ptr<Secp256k1Init> ecc;
698+
std::unique_ptr<ECC_Context> ecc;
710699

711700
if (command == "nversion")
712701
MutateTxVersion(tx, commandVal);
@@ -726,18 +715,18 @@ static void MutateTx(CMutableTransaction& tx, const std::string& command,
726715
else if (command == "outaddr")
727716
MutateTxAddOutAddr(tx, commandVal);
728717
else if (command == "outpubkey") {
729-
ecc.reset(new Secp256k1Init());
718+
ecc.reset(new ECC_Context());
730719
MutateTxAddOutPubKey(tx, commandVal);
731720
} else if (command == "outmultisig") {
732-
ecc.reset(new Secp256k1Init());
721+
ecc.reset(new ECC_Context());
733722
MutateTxAddOutMultiSig(tx, commandVal);
734723
} else if (command == "outscript")
735724
MutateTxAddOutScript(tx, commandVal);
736725
else if (command == "outdata")
737726
MutateTxAddOutData(tx, commandVal);
738727

739728
else if (command == "sign") {
740-
ecc.reset(new Secp256k1Init());
729+
ecc.reset(new ECC_Context());
741730
MutateTxSign(tx, commandVal);
742731
}
743732

src/bitcoin-wallet.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,9 @@ MAIN_FUNCTION
128128
return EXIT_FAILURE;
129129
}
130130

131-
ECC_Start();
131+
ECC_Context ecc_context{};
132132
if (!wallet::WalletTool::ExecuteWalletToolFunc(args, command->command)) {
133133
return EXIT_FAILURE;
134134
}
135-
ECC_Stop();
136135
return EXIT_SUCCESS;
137136
}

0 commit comments

Comments
 (0)