Skip to content

Commit 507e1b3

Browse files
authored
MS: fixed error in handeling of tx locking when a tx comes from a minted address, also added a check for protocol change (#18)
1 parent 95426e4 commit 507e1b3

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

daemon/main.cpp

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ bool MoneyRange(CAmount nValueOut)
996996
// Stop transactions from happening during locking period
997997
bool CheckIfLockPeriodIsActive(CTransaction tx)
998998
{
999-
bool transactionOK = false;
999+
//bool transactionOK = false;
10001000
restclient *rc = get_restclient();
10011001

10021002
if (!rc->getdatafromrestserver()) {
@@ -1005,22 +1005,42 @@ bool CheckIfLockPeriodIsActive(CTransaction tx)
10051005

10061006
std::vector<mint> mints = rc->getMints();
10071007

1008+
CTransaction prevoutTx;
1009+
uint256 prevoutHashBlock;
10081010
for (mint mint : mints) {
1011+
CBitcoinAddress address = mint.getAddress();
1012+
if (!address.IsValid()) {
1013+
continue;
1014+
}
1015+
for (unsigned int j = 0; j < tx.vin.size(); j++) {
1016+
if (GetTransaction(tx.vin[j].prevout.hash, prevoutTx, prevoutHashBlock)) {
1017+
if(prevoutTx.vout[tx.vin[j].prevout.n].scriptPubKey == GetScriptForDestination(address.Get())) {
1018+
for (unsigned int y = 0; y < tx.vout.size(); y++) {
1019+
if (prevoutTx.vout[tx.vin[j].prevout.n].scriptPubKey != tx.vout[y].scriptPubKey) {
1020+
return true;
1021+
}
1022+
}
1023+
}
1024+
}
1025+
}
1026+
}
1027+
1028+
/*for (mint mint : mints) {
10091029
CBitcoinAddress address = mint.getAddress();
10101030
for (CTxIn txIn : tx.vin) {
10111031
for (CTxOut txOut : tx.vout) {
10121032
if (txIn.prevPubKey == GetScriptForDestination(address.Get())) {
1013-
if (txIn.prevPubKey == txOut.scriptPubKey) {
1033+
if (txIn.prevPubKey != txOut.scriptPubKey) {
10141034
return true;
10151035
} else {
1016-
return false;
1036+
transactionOK = false;
10171037
}
10181038
}
10191039
}
10201040
}
1021-
}
1041+
}*/
10221042

1023-
return transactionOK;
1043+
return false;
10241044
}
10251045

10261046
bool CheckZerocoinMint(const uint256& txHash, const CTxOut& txout, CValidationState& state, bool fCheckOnly)
@@ -1176,7 +1196,7 @@ bool CheckTransaction(const CTransaction& tx, bool fZerocoinActive, bool fReject
11761196

11771197
if(callHedgehog) {
11781198
if (CheckIfLockPeriodIsActive(tx)) {
1179-
return state.DoS(100, error("CheckTransaction() : transaction from minted address found"));
1199+
return state.DoS(1, error("CheckTransaction() : transaction from minted address found"));
11801200
}
11811201
}
11821202

@@ -4281,7 +4301,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
42814301

42824302
for (CTransaction trans : block.vtx) {
42834303
if (CheckIfLockPeriodIsActive(trans)) {
4284-
return state.DoS(100, error("CheckBlock() : transaction from minted address found"));
4304+
return state.DoS(1, error("CheckBlock() : transaction from minted address found"));
42854305
}
42864306
}
42874307

daemon/restclient.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ bool restclient::hasMintingSpork()
189189
return has_minting_spork;
190190
}
191191

192+
if (getMints().size() < 5) {
193+
return false;
194+
}
195+
192196
char* target = "/gridspork/mint-storage";
193197
int version = 11;
194198

0 commit comments

Comments
 (0)