Skip to content

Commit 668e2f8

Browse files
committed
tools: Use ECC_Context helper in bitcoin-tx and bitcoin-wallet tools
1 parent 7184d36 commit 668e2f8

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
@@ -694,21 +694,10 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
694694
tx = mergedTx;
695695
}
696696

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

713702
if (command == "nversion")
714703
MutateTxVersion(tx, commandVal);
@@ -728,18 +717,18 @@ static void MutateTx(CMutableTransaction& tx, const std::string& command,
728717
else if (command == "outaddr")
729718
MutateTxAddOutAddr(tx, commandVal);
730719
else if (command == "outpubkey") {
731-
ecc.reset(new Secp256k1Init());
720+
ecc.reset(new ECC_Context());
732721
MutateTxAddOutPubKey(tx, commandVal);
733722
} else if (command == "outmultisig") {
734-
ecc.reset(new Secp256k1Init());
723+
ecc.reset(new ECC_Context());
735724
MutateTxAddOutMultiSig(tx, commandVal);
736725
} else if (command == "outscript")
737726
MutateTxAddOutScript(tx, commandVal);
738727
else if (command == "outdata")
739728
MutateTxAddOutData(tx, commandVal);
740729

741730
else if (command == "sign") {
742-
ecc.reset(new Secp256k1Init());
731+
ecc.reset(new ECC_Context());
743732
MutateTxSign(tx, commandVal);
744733
}
745734

src/bitcoin-wallet.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,9 @@ MAIN_FUNCTION
132132
return EXIT_FAILURE;
133133
}
134134

135-
ECC_Start();
135+
ECC_Context ecc_context{};
136136
if (!wallet::WalletTool::ExecuteWalletToolFunc(args, command->command)) {
137137
return EXIT_FAILURE;
138138
}
139-
ECC_Stop();
140139
return EXIT_SUCCESS;
141140
}

0 commit comments

Comments
 (0)