Skip to content

Commit efded3c

Browse files
laanwjcodablock
authored andcommitted
Merge bitcoin#7551: Add importmulti RPC call
215caba Add consistency check to RPC call importmulti (Pedro Branco) cb08fdb Add importmulti rpc call (Pedro Branco)
1 parent bd8e9fb commit efded3c

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
@@ -154,6 +154,7 @@
154154
'preciousblock.py',
155155
'importprunedfunds.py',
156156
'signmessages.py',
157+
'importmulti.py',
157158
]
158159
if ENABLE_ZMQ:
159160
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
@@ -464,6 +464,9 @@ class CChain {
464464

465465
/** Find the last common block between this chain and a block index entry. */
466466
const CBlockIndex *FindFork(const CBlockIndex *pindex) const;
467+
468+
/** Find the most recent block with timestamp lower than the given. */
469+
CBlockIndex* FindLatestBefore(int64_t nTime) const;
467470
};
468471

469472
#endif // BITCOIN_CHAIN_H

src/rpc/client.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
117117
{ "importaddress", 2 },
118118
{ "importaddress", 3 },
119119
{ "importpubkey", 2 },
120+
{ "importmulti", 0 },
121+
{ "importmulti", 1 },
120122
{ "verifychain", 0 },
121123
{ "verifychain", 1 },
122124
{ "keypoolrefill", 0 },

0 commit comments

Comments
 (0)