Skip to content

Commit be2ea19

Browse files
author
sproxet
committed
Refactor transaction creation.
1 parent 92a3d42 commit be2ea19

21 files changed

Lines changed: 2137 additions & 408 deletions

src/Makefile.test.include

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ BITCOIN_TESTS += \
192192
wallet/test/lelantus_tests.cpp \
193193
wallet/test/sigma_tests.cpp \
194194
wallet/test/mnemonic_tests.cpp \
195-
wallet/test/txbuilder_tests.cpp
195+
wallet/test/sigmatxbuilder_tests.cpp \
196+
wallet/test/createtransaction_tests.cpp
196197
endif
197198

198199
test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) -ltor

src/elysium/elysium.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2291,7 +2291,7 @@ int elysium::WalletTxBuilder(
22912291
switch (inputMode) {
22922292
case InputMode::NORMAL:
22932293
// Ask the wallet to create the transaction (note mining fee determined by Bitcoin Core params)
2294-
if (!pwalletMain->CreateTransaction(vecRecipients, wtxNew, reserveKey, nFeeRet, nChangePosInOut, strFailReason, &coinControl)) {
2294+
if (!pwalletMain->CreateTransaction(vecRecipients, wtxNew, &reserveKey, nFeeRet, nChangePosInOut, strFailReason, &coinControl)) {
22952295
PrintToLog("%s: ERROR: wallet transaction creation failed: %s\n", __func__, strFailReason);
22962296
return MP_ERR_CREATE_TX;
22972297
}

src/llmq/quorums_instantsend.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ class CInstantSendDb
7575
class CInstantSendManager : public CRecoveredSigsListener
7676
{
7777
private:
78-
CCriticalSection cs;
79-
CInstantSendDb db;
80-
8178
std::thread workThread;
8279
CThreadInterrupt workInterrupt;
8380

@@ -113,6 +110,9 @@ class CInstantSendManager : public CRecoveredSigsListener
113110
std::atomic_bool isNewInstantSendEnabled{false};
114111

115112
public:
113+
CCriticalSection cs;
114+
CInstantSendDb db;
115+
116116
CInstantSendManager(CDBWrapper& _llmqDb);
117117
~CInstantSendManager();
118118

src/primitives/transaction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class CTxOut
170170
public:
171171
CAmount nValue;
172172
CScript scriptPubKey;
173-
int nRounds;
173+
int nRounds = -10;
174174

175175
CTxOut()
176176
{

src/qt/walletmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
344344

345345
CWalletTx *newTx = transaction.getTransaction();
346346
CReserveKey *keyChange = transaction.getPossibleKeyChange();
347-
bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, nChangePosRet, strFailReason, coinControl);
347+
bool fCreated = wallet->CreateTransaction(vecSend, *newTx, keyChange, nFeeRequired, nChangePosRet, strFailReason, coinControl);
348348
transaction.setTransactionFee(nFeeRequired);
349349
if (fSubtractFeeFromAmount && fCreated)
350350
transaction.reassignAmounts(nChangePosRet);

src/rpc/rpcevo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static void FundSpecialTx(CWallet* pwallet, CMutableTransaction& tx, const Speci
213213
int nChangePos = -1;
214214
std::string strFailReason;
215215

216-
if (!pwallet->CreateTransaction(vecSend, wtx, reservekey, nFee, nChangePos, strFailReason, &coinControl, false, tx.vExtraPayload.size())) {
216+
if (!pwallet->CreateTransaction(vecSend, wtx, &reservekey, nFee, nChangePos, strFailReason, &coinControl, false, tx.vExtraPayload.size())) {
217217
throw JSONRPCError(RPC_INTERNAL_ERROR, strFailReason);
218218
}
219219

src/script/script.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,16 @@ unsigned int CScript::GetSigOpCount(const CScript& scriptSig) const
211211
return subscript.GetSigOpCount(true);
212212
}
213213

214+
bool CScript::IsPayToPublicKey() const {
215+
if (size() != 35) return false;
216+
217+
opcodetype opcode;
218+
const_iterator pc = begin();
219+
GetOp(pc, opcode);
220+
GetOp(pc, opcode);
221+
return opcode == OP_CHECKSIG;
222+
}
223+
214224
bool CScript::IsNormalPaymentScript() const
215225
{
216226
if(this->size() != 25) return false;

src/script/script.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ class CScript : public CScriptBase
653653
unsigned int GetSigOpCount(const CScript& scriptSig) const;
654654
bool IsNormalPaymentScript() const;
655655

656+
bool IsPayToPublicKey() const;
656657
bool IsPayToPublicKeyHash() const;
657658

658659
bool IsPayToScriptHash() const;

src/sync.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "utilstrencodings.h"
99

1010
#include <stdio.h>
11-
11+
#include <set>
1212
#include <boost/foreach.hpp>
1313
#include <boost/thread.hpp>
1414

@@ -57,7 +57,7 @@ struct CLockLocation {
5757

5858
typedef std::vector<std::pair<void*, CLockLocation> > LockStack;
5959
typedef std::map<std::pair<void*, void*>, LockStack> LockOrders;
60-
typedef std::set<std::pair<void*, void*> > InvLockOrders;
60+
typedef std::set<std::pair<void*, void*>> InvLockOrders;
6161

6262
struct LockData {
6363
// Very ugly hack: as the global constructs and destructors run single
@@ -164,7 +164,7 @@ void AssertLockNotHeldInternal(const char* pszName, const char* pszFile, int nLi
164164
if (i.first == cs) {
165165
fprintf(stderr, "Assertion failed: lock %s held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str());
166166
abort();
167-
}
167+
}
168168
}
169169
}
170170

src/test/test_bitcoin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ TestingSetup::TestingSetup(const std::string& chainName, std::string suf) : Basi
114114

115115
// Init HD mint
116116

117-
// Create new keyUser and set as default key
118-
// generate a new master key
117+
pwalletMain->GenerateNewMnemonic();
118+
119119
CPubKey masterPubKey = pwalletMain->GenerateNewHDMasterKey();
120120
pwalletMain->SetHDMasterKey(masterPubKey);
121121
CPubKey newDefaultKey;

0 commit comments

Comments
 (0)