Skip to content

Commit f2d7056

Browse files
committed
Merge #7551: Add importmulti RPC call
215caba Add consistency check to RPC call importmulti (Pedro Branco) cb08fdb Add importmulti rpc call (Pedro Branco)
2 parents c587577 + 215caba commit f2d7056

File tree

7 files changed

+797
-0
lines changed

7 files changed

+797
-0
lines changed

qa/pull-tester/rpc-tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
'signmessages.py',
146146
'p2p-compactblocks.py',
147147
'nulldummy.py',
148+
'importmulti.py',
148149
]
149150
if ENABLE_ZMQ:
150151
testScripts.append('zmq_test.py')

qa/rpc-tests/importmulti.py

Lines changed: 360 additions & 0 deletions
Large diffs are not rendered by default.

src/chain.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ const CBlockIndex *CChain::FindFork(const CBlockIndex *pindex) const {
6161
return pindex;
6262
}
6363

64+
CBlockIndex* CChain::FindLatestBefore(int64_t nTime) const
65+
{
66+
std::vector<CBlockIndex*>::const_iterator lower = std::lower_bound(vChain.begin(), vChain.end(), nTime,
67+
[](CBlockIndex* pBlock, const int64_t& time) -> bool { return pBlock->GetBlockTime() < time; });
68+
return (lower == vChain.end() ? NULL : *lower);
69+
}
70+
6471
/** Turn the lowest '1' bit in the binary representation of a number into a '0'. */
6572
int static inline InvertLowestOne(int n) { return n & (n - 1); }
6673

src/chain.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ class CChain {
459459

460460
/** Find the last common block between this chain and a block index entry. */
461461
const CBlockIndex *FindFork(const CBlockIndex *pindex) const;
462+
463+
/** Find the most recent block with timestamp lower than the given. */
464+
CBlockIndex* FindLatestBefore(int64_t nTime) const;
462465
};
463466

464467
#endif // BITCOIN_CHAIN_H

src/rpc/client.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
9595
{ "importaddress", 2 },
9696
{ "importaddress", 3 },
9797
{ "importpubkey", 2 },
98+
{ "importmulti", 0 },
99+
{ "importmulti", 1 },
98100
{ "verifychain", 0 },
99101
{ "verifychain", 1 },
100102
{ "keypoolrefill", 0 },

0 commit comments

Comments
 (0)