Skip to content

Commit d515aa9

Browse files
authored
Merge pull request #265 from pastelnetwork/PSL-1249
1) [PSL-1249] pasteld: create index for Sender2Recipient mapping and API using it (`getaddressutxosextra`) 2) Fix for "simple" flag of `getaddressutxosextra` 3) Skip dust checks on transactions to burnaddress
2 parents 9ee4175 + 2a48cb6 commit d515aa9

Some content is hidden

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

44 files changed

+2043
-1323
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ venv/
55
venv27/
66

77
compile_commands.json
8+
pastel-config.h.in
89

910
*.tar.gz
1011
*.deb

build-aux/vs2022/libbitcoin_server/libbitcoin_server.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
<ClCompile Include="..\..\..\src\timedata.cpp" />
199199
<ClCompile Include="..\..\..\src\torcontrol.cpp" />
200200
<ClCompile Include="..\..\..\src\txdb\txdb.cpp" />
201+
<ClCompile Include="..\..\..\src\txdb\txidxprocessor.cpp" />
201202
<ClCompile Include="..\..\..\src\txmempool.cpp" />
202203
<ClCompile Include="..\..\..\src\validationinterface.cpp" />
203204
<ClCompile Include="..\..\vs\port\cyclicbarrier\cyclicbarrier.cpp" />
@@ -326,9 +327,12 @@
326327
<ClInclude Include="..\..\..\src\timedata.h" />
327328
<ClInclude Include="..\..\..\src\torcontrol.h" />
328329
<ClInclude Include="..\..\..\src\txdb\addressindex.h" />
330+
<ClInclude Include="..\..\..\src\txdb\fundstransferindex.h" />
331+
<ClInclude Include="..\..\..\src\txdb\index_defs.h" />
329332
<ClInclude Include="..\..\..\src\txdb\spentindex.h" />
330333
<ClInclude Include="..\..\..\src\txdb\timestampindex.h" />
331334
<ClInclude Include="..\..\..\src\txdb\txdb.h" />
335+
<ClInclude Include="..\..\..\src\txdb\txidxprocessor.h" />
332336
<ClInclude Include="..\..\..\src\txmempool.h" />
333337
<ClInclude Include="..\..\..\src\txmempool_entry.h" />
334338
<ClInclude Include="..\..\..\src\ui_interface.h" />

build-aux/vs2022/libbitcoin_server/libbitcoin_server.vcxproj.filters

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,9 @@
373373
<ClCompile Include="..\..\..\src\txdb\txdb.cpp">
374374
<Filter>Source Files\txdb</Filter>
375375
</ClCompile>
376+
<ClCompile Include="..\..\..\src\txdb\txidxprocessor.cpp">
377+
<Filter>Source Files\txdb</Filter>
378+
</ClCompile>
376379
</ItemGroup>
377380
<ItemGroup>
378381
<ClInclude Include="..\..\..\src\addrman.h">
@@ -771,5 +774,14 @@
771774
<ClInclude Include="..\..\..\src\txdb\timestampindex.h">
772775
<Filter>Source Files\txdb</Filter>
773776
</ClInclude>
777+
<ClInclude Include="..\..\..\src\txdb\txidxprocessor.h">
778+
<Filter>Source Files\txdb</Filter>
779+
</ClInclude>
780+
<ClInclude Include="..\..\..\src\txdb\index_defs.h">
781+
<Filter>Source Files\txdb</Filter>
782+
</ClInclude>
783+
<ClInclude Include="..\..\..\src\txdb\fundstransferindex.h">
784+
<Filter>Source Files\txdb</Filter>
785+
</ClInclude>
774786
</ItemGroup>
775787
</Project>

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ AC_PREREQ([2.60])
33
define(_CLIENT_VERSION_MAJOR, 2)
44
define(_CLIENT_VERSION_MINOR, 2)
55
define(_CLIENT_VERSION_REVISION, 7)
6-
define(_CLIENT_VERSION_BUILD, 1)
6+
define(_CLIENT_VERSION_BUILD, 2)
77
define(_ZC_BUILD_VAL,
88
m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD),
99
m4_eval(_CLIENT_VERSION_BUILD < 50), 1,

src/Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,10 @@ PASTEL_CORE_H = \
336336
core_io.h \
337337
core_memusage.h \
338338
txdb/addressindex.h \
339+
txdb/fundstransferindex.h \
340+
txdb/index_defs.h \
339341
txdb/spentindex.h \
342+
txdb/txidxprocessor.h \
340343
txdb/timestampindex.h \
341344
txdb/txdb.h \
342345
deprecation.h \
@@ -375,7 +378,6 @@ PASTEL_CORE_H = \
375378
noui.h \
376379
orphan-tx.h\
377380
policy/fees.h \
378-
port_config.h \
379381
primitives/block.h \
380382
primitives/transaction.h \
381383
protocol.h \
@@ -489,6 +491,7 @@ libbitcoin_server_a_SOURCES = \
489491
timedata.cpp \
490492
torcontrol.cpp \
491493
txdb/txdb.cpp \
494+
txdb/txidxprocessor.cpp \
492495
txmempool.cpp \
493496
validationinterface.cpp \
494497
$(MNODE_CPP) \

src/accept_to_mempool.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const CChainParams& ch
7979
}
8080
}
8181

82+
const auto& destBurnAddress = chainparams.getPastelBurnAddressHash();
8283
for (const auto& txin : tx.vin)
8384
{
8485
// Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed
@@ -115,7 +116,16 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const CChainParams& ch
115116
else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) {
116117
reason = "bare-multisig";
117118
return false;
118-
} else if (txout.IsDust(gl_ChainOptions.minRelayTxFee)) {
119+
}
120+
121+
// skip dust check if transaction is to the burn transaction
122+
bool bSkipDustCheck = false;
123+
if ((whichType == TX_PUBKEYHASH) || (whichType == TX_SCRIPTHASH))
124+
{
125+
const uint160 addressHash = txout.scriptPubKey.AddressHash();
126+
bSkipDustCheck = (addressHash == destBurnAddress);
127+
}
128+
if (!bSkipDustCheck && txout.IsDust(gl_ChainOptions.minRelayTxFee)) {
119129
reason = "dust";
120130
return false;
121131
}

src/chain.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,13 @@ class CDiskBlockIndex : public CBlockIndex
383383
}
384384
};
385385

386+
typedef enum class _BlockDisconnectResult
387+
{
388+
OK, // All good.
389+
UNCLEAN, // Rolled back, but UTXO set was inconsistent with block.
390+
FAILED // Something else went wrong.
391+
} BlockDisconnectResult;
392+
386393
using block_index_cvector_t = std::vector<const CBlockIndex*>;
387394
using block_index_vector_t = std::vector<CBlockIndex*>;
388395

src/chain_options.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ atomic_bool fInsightExplorer = false;
1010
atomic_bool fAddressIndex = false;
1111
atomic_bool fSpentIndex = true;
1212
atomic_bool fTimestampIndex = false;
13+
atomic_bool fFundsTransferIndex = false;
1314

1415
CChainOptions gl_ChainOptions;
1516

src/chain_options.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,15 @@ extern std::atomic_bool fSpentIndex;
4343

4444
// Maintain a full timestamp index, used to query for blocks within a time range
4545
extern std::atomic_bool fTimestampIndex;
46+
47+
// Maintain a full funds transfer index
48+
extern std::atomic_bool fFundsTransferIndex;
4649
// END insightexplorer
4750

51+
// range of block heights from start to end
52+
using height_range_t = std::pair<uint32_t, uint32_t>;
53+
using height_range_opt_t = std::optional<height_range_t>;
54+
4855
class CChainOptions
4956
{
5057
public:

src/chainparams.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Genesis block for RegTest found
4242
#include <utils/utilstrencodings.h>
4343
#include <utils/arith_uint256.h>
4444
#include <key_io.h>
45-
#include <main.h>
4645
#include <net.h>
4746
#include <netmsg/netconsts.h>
4847
#include <crypto/equihash.h>
@@ -350,6 +349,20 @@ static CBlock CreateRegtestGenesisBlock()
350349
return block;
351350
}
352351

352+
bool CChainParams::DecodePastelBurnAddress()
353+
{
354+
KeyIO keyIO(*this);
355+
ScriptType scriptType;
356+
const CTxDestination dest = keyIO.DecodeDestination(m_sPastelBurnAddress);
357+
return GetTxDestinationHash(dest, m_pastelBurnAddressHash, scriptType);
358+
}
359+
360+
constexpr size_t equihash_parameters_acceptable(const int N, const int K) noexcept
361+
{
362+
return ((CBlockHeader::HEADER_SIZE + equihash_solution_size(N, K)) * MAX_HEADERS_RESULTS < \
363+
MAX_PROTOCOL_MESSAGE_LENGTH - 1000);
364+
}
365+
353366
/**
354367
* Main network
355368
*/
@@ -703,6 +716,8 @@ class CRegTestParams : public CChainParams
703716
{
704717
strNetworkID = "regtest";
705718
strCurrencyUnits = "REG";
719+
// cUUjBtKN8BRriP1STe1KkEhJUpdARf8tj9T5gKuJPuY5mjtd2jP5
720+
m_sPastelBurnAddress = "tPotfXKvYRAmJepR8rm849pRP2nmbyt2bGu";
706721
bip44CoinType = 1;
707722
consensus.nSubsidyHalvingInterval = 150;
708723
consensus.nMajorityEnforceBlockUpgrade = 750;
@@ -740,7 +755,6 @@ class CRegTestParams : public CChainParams
740755
pchMessageStart[1] = 0xd8;
741756
pchMessageStart[2] = 0xfa;
742757
pchMessageStart[3] = 0x9e;
743-
//vAlertPubKey = ParseHex("04b985ccafe6d17ac5d84cb8c06a69cefad733ee96b4b93bcf5ef0897778c227ee7e74e7680cc219236e4c6a609dbcdeb5bf65cea9c2576c2a0fbef590657c8e7a");
744758
vAlertPubKey = ParseHex("04d8a5b9bf6ef2396204fc879d370c85b3ccd665b6a06b9600165ceed4233ca38d27010abd3b6e607b46663ce21e8473df0e30f1bf7e425a3bdd58d2a6d1bb2049");
745759
nDefaultPort = REGTEST_DEFAULT_PORT;
746760
m_nPruneAfterHeight = 1000;
@@ -836,6 +850,8 @@ unique_ptr<const CChainParams> CreateChainParams(const ChainNetwork network)
836850
ChainParams = make_unique<CMainParams>();
837851
break;
838852
}
853+
if (ChainParams)
854+
ChainParams->DecodePastelBurnAddress();
839855
return std::move(ChainParams);
840856
}
841857

0 commit comments

Comments
 (0)