Skip to content

Commit

Permalink
Merge bitcoin#7551: Add importmulti RPC call
Browse files Browse the repository at this point in the history
215caba Add consistency check to RPC call importmulti (Pedro Branco)
cb08fdb Add importmulti rpc call (Pedro Branco)
  • Loading branch information
laanwj committed Oct 20, 2016
2 parents c587577 + 215caba commit f2d7056
Show file tree
Hide file tree
Showing 7 changed files with 797 additions and 0 deletions.
1 change: 1 addition & 0 deletions qa/pull-tester/rpc-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
'signmessages.py',
'p2p-compactblocks.py',
'nulldummy.py',
'importmulti.py',
]
if ENABLE_ZMQ:
testScripts.append('zmq_test.py')
Expand Down
360 changes: 360 additions & 0 deletions qa/rpc-tests/importmulti.py

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ const CBlockIndex *CChain::FindFork(const CBlockIndex *pindex) const {
return pindex;
}

CBlockIndex* CChain::FindLatestBefore(int64_t nTime) const
{
std::vector<CBlockIndex*>::const_iterator lower = std::lower_bound(vChain.begin(), vChain.end(), nTime,
[](CBlockIndex* pBlock, const int64_t& time) -> bool { return pBlock->GetBlockTime() < time; });
return (lower == vChain.end() ? NULL : *lower);
}

/** Turn the lowest '1' bit in the binary representation of a number into a '0'. */
int static inline InvertLowestOne(int n) { return n & (n - 1); }

Expand Down
3 changes: 3 additions & 0 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ class CChain {

/** Find the last common block between this chain and a block index entry. */
const CBlockIndex *FindFork(const CBlockIndex *pindex) const;

/** Find the most recent block with timestamp lower than the given. */
CBlockIndex* FindLatestBefore(int64_t nTime) const;
};

#endif // BITCOIN_CHAIN_H
2 changes: 2 additions & 0 deletions src/rpc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "importaddress", 2 },
{ "importaddress", 3 },
{ "importpubkey", 2 },
{ "importmulti", 0 },
{ "importmulti", 1 },
{ "verifychain", 0 },
{ "verifychain", 1 },
{ "keypoolrefill", 0 },
Expand Down
Loading

0 comments on commit f2d7056

Please sign in to comment.