Skip to content

Commit 65ed777

Browse files
committed
remove legacy peg-in/withdrawlocks
1 parent b2bbc67 commit 65ed777

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+178
-1793
lines changed

qa/rpc-tests/pegging.py

Lines changed: 0 additions & 232 deletions
This file was deleted.

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ endif
458458

459459
libelementsconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info 1:0:0 $(RELDFLAGS)
460460
libelementsconsensus_la_LIBADD = $(LIBSECP256K1)
461-
libelementsconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL -DBITCOIN_SCRIPT_NO_CALLRPC
461+
libelementsconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
462462
libelementsconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
463463

464464
endif

src/Makefile.test.include

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ BITCOIN_TESTS =\
100100
test/hash_tests.cpp \
101101
test/key_tests.cpp \
102102
test/limitedmap_tests.cpp \
103-
test/lockedutxo_tests.cpp \
104103
test/withdrawspent_tests.cpp \
105104
test/dbwrapper_tests.cpp \
106105
test/main_tests.cpp \

src/bench/mempool_eviction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ static void AddTx(const CTransaction& tx, const CAmount& nFee, CTxMemPool& pool)
1616
unsigned int nHeight = 1;
1717
bool spendsCoinbase = false;
1818
unsigned int sigOpCost = 4;
19-
std::set<std::pair<uint256, COutPoint> > setWithdrawsSpent;
19+
std::set<std::pair<uint256, COutPoint> > setPeginsSpent;
2020
LockPoints lp;
2121
pool.addUnchecked(tx.GetHash(), CTxMemPoolEntry(
2222
MakeTransactionRef(tx), nFee, nTime, dPriority, nHeight,
23-
0, spendsCoinbase, sigOpCost, lp, setWithdrawsSpent));
23+
0, spendsCoinbase, sigOpCost, lp, setPeginsSpent));
2424
}
2525

2626
// Right now this is only testing eviction performance in an extremely small

src/bench/verify_script.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void VerifyScriptBench(benchmark::State& state)
8181
txCredit.vout[0].scriptPubKey,
8282
&txSpend.wit.vtxinwit[0].scriptWitness,
8383
flags,
84-
MutableTransactionNoWithdrawsSignatureChecker(&txSpend, 0, txCredit.vout[0].nValue),
84+
MutableTransactionSignatureChecker(&txSpend, 0, txCredit.vout[0].nValue),
8585
&err);
8686
assert(err == SCRIPT_ERR_OK);
8787
assert(success);

src/bitcoin-tx.cpp

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,10 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
701701

702702
// ... and merge in other signatures:
703703
BOOST_FOREACH(const CTransaction& txv, txVariants)
704-
sigdata = CombineSignatures(prevPubKey, MutableTransactionNoWithdrawsSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i));
704+
sigdata = CombineSignatures(prevPubKey, MutableTransactionSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i));
705705
UpdateTransaction(mergedTx, i, sigdata);
706706

707-
if (!VerifyScript(txin.scriptSig, prevPubKey, (mergedTx.wit.vtxinwit.size() > i) ? &mergedTx.wit.vtxinwit[i].scriptWitness : NULL, STANDARD_SCRIPT_VERIFY_FLAGS, MutableTransactionNoWithdrawsSignatureChecker(&mergedTx, i, amount)))
707+
if (!VerifyScript(txin.scriptSig, prevPubKey, (mergedTx.wit.vtxinwit.size() > i) ? &mergedTx.wit.vtxinwit[i].scriptWitness : NULL, STANDARD_SCRIPT_VERIFY_FLAGS, MutableTransactionSignatureChecker(&mergedTx, i, amount)))
708708
fComplete = false;
709709
}
710710

@@ -716,58 +716,6 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
716716
tx = mergedTx;
717717
}
718718

719-
static void MutateTxPeginSign(CMutableTransaction& tx, const std::string& flagStr)
720-
{
721-
if (!registers.count("peginkeys"))
722-
throw std::runtime_error("peginkeys register variable must be set.");
723-
UniValue keysObj = registers["peginkeys"];
724-
725-
if (!keysObj.isObject())
726-
throw std::runtime_error("peginkeysObjs must be an object");
727-
std::map<std::string,UniValue::VType> types = boost::assign::map_list_of("contract",UniValue::VSTR)("txoutproof",UniValue::VSTR)("tx",UniValue::VSTR)("nout",UniValue::VNUM);
728-
if (!keysObj.checkObject(types))
729-
throw std::runtime_error("peginkeysObjs internal object typecheck fail");
730-
731-
std::vector<unsigned char> contractData(ParseHexUV(keysObj["contract"], "contract"));
732-
std::vector<unsigned char> txoutproofData(ParseHexUV(keysObj["txoutproof"], "txoutproof"));
733-
std::vector<unsigned char> txData(ParseHexUV(keysObj["tx"], "tx"));
734-
int nOut = atoi(keysObj["nout"].getValStr());
735-
736-
if (contractData.size() != 40)
737-
throw std::runtime_error("contract must be 40 bytes");
738-
739-
CDataStream ssProof(txoutproofData,SER_NETWORK, PROTOCOL_VERSION);
740-
Sidechain::Bitcoin::CMerkleBlock merkleBlock;
741-
ssProof >> merkleBlock;
742-
743-
CDataStream ssTx(txData, SER_NETWORK, PROTOCOL_VERSION);
744-
Sidechain::Bitcoin::CTransactionRef txBTCRef;
745-
ssTx >> txBTCRef;
746-
Sidechain::Bitcoin::CTransaction txBTC(*txBTCRef);
747-
748-
std::vector<uint256> transactionHashes;
749-
std::vector<unsigned int> transactionIndices;
750-
if (!CheckBitcoinProof(merkleBlock.header.GetHash(), merkleBlock.header.nBits) ||
751-
merkleBlock.txn.ExtractMatches(transactionHashes, transactionIndices) != merkleBlock.header.hashMerkleRoot ||
752-
transactionHashes.size() != 1 ||
753-
transactionHashes[0] != txBTC.GetHash())
754-
throw std::runtime_error("txoutproof is invalid or did not match tx");
755-
756-
if (nOut < 0 || (unsigned int) nOut >= txBTC.vout.size())
757-
throw std::runtime_error("nout must be >= 0, < txout count");
758-
759-
CScript scriptSig;
760-
scriptSig << contractData;
761-
scriptSig.PushWithdraw(txoutproofData);
762-
scriptSig.PushWithdraw(txData);
763-
scriptSig << nOut;
764-
765-
//TODO: Verify the withdraw proof
766-
for (unsigned int i = 0; i < tx.vin.size(); i++) {
767-
tx.vin[i].scriptSig = scriptSig;
768-
}
769-
}
770-
771719
class Secp256k1Init
772720
{
773721
ECCVerifyHandle globalVerifyHandle;
@@ -815,17 +763,13 @@ static void MutateTx(CMutableTransaction& tx, const std::string& command,
815763
} else if (command == "blind") {
816764
if (!ecc) { ecc.reset(new Secp256k1Init()); }
817765
MutateTxBlind(tx, commandVal);
818-
} else if (command == "peginsign")
819-
MutateTxPeginSign(tx, commandVal);
820-
821-
else if (command == "load")
766+
} else if (command == "load") {
822767
RegisterLoad(commandVal);
823-
824-
else if (command == "set")
768+
} else if (command == "set") {
825769
RegisterSet(commandVal);
826-
827-
else
770+
} else {
828771
throw std::runtime_error("unknown command");
772+
}
829773
}
830774

831775
static void OutputTxJSON(const CTransaction& tx)

src/consensus/validation.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ static const unsigned char REJECT_NONSTANDARD = 0x40;
1717
static const unsigned char REJECT_DUST = 0x41;
1818
static const unsigned char REJECT_INSUFFICIENTFEE = 0x42;
1919
static const unsigned char REJECT_CHECKPOINT = 0x43;
20-
static const unsigned char REJECT_SCRIPT = 0x44;
2120

2221
/** Capture information about block/transaction validation */
2322
class CValidationState {

src/policy/policy.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,6 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
122122
{
123123
const CTxOut& prev = mapInputs.GetOutputFor(tx.vin[i]);
124124

125-
if (prev.scriptPubKey.IsWithdrawLock()) {
126-
if (!tx.vin[i].scriptSig.IsWithdrawProof()) {
127-
if (tx.vout.size() < i)
128-
if (!tx.vout[i].nValue.IsExplicit() || tx.vout[i].nValue.GetAmount() > MAX_MONEY / 100)
129-
return false;
130-
}
131-
continue;
132-
}
133-
134125
// Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed
135126
// keys. (remember the 520 byte limit on redeemScript size) That works
136127
// out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627

0 commit comments

Comments
 (0)