update wallet restore, generate new merkle proof for coinbase outputs (#1008)
This commit is contained in:
+8
-1
@@ -30,7 +30,7 @@ use pipe;
|
||||
use store;
|
||||
use txhashset;
|
||||
use types::*;
|
||||
use util::secp::pedersen::RangeProof;
|
||||
use util::secp::pedersen::{Commitment, RangeProof};
|
||||
use util::LOGGER;
|
||||
|
||||
/// Orphan pool size is limited by MAX_ORPHAN_SIZE
|
||||
@@ -507,6 +507,13 @@ impl Chain {
|
||||
Ok(merkle_proof)
|
||||
}
|
||||
|
||||
/// Return a merkle proof valid for the current output pmmr state at the
|
||||
/// given pos
|
||||
pub fn get_merkle_proof_for_pos(&self, commit: Commitment) -> Result<MerkleProof, String> {
|
||||
let mut txhashset = self.txhashset.write().unwrap();
|
||||
txhashset.merkle_proof(commit)
|
||||
}
|
||||
|
||||
/// Returns current txhashset roots
|
||||
pub fn get_txhashset_roots(&self) -> (Hash, Hash, Hash) {
|
||||
let mut txhashset = self.txhashset.write().unwrap();
|
||||
|
||||
@@ -205,6 +205,14 @@ impl TxHashSet {
|
||||
(output_pmmr.root(), rproof_pmmr.root(), kernel_pmmr.root())
|
||||
}
|
||||
|
||||
/// build a new merkle proof for the given position
|
||||
pub fn merkle_proof(&mut self, commit: Commitment) -> Result<MerkleProof, String> {
|
||||
let pos = self.commit_index.get_output_pos(&commit).unwrap();
|
||||
let output_pmmr: PMMR<OutputIdentifier, _> =
|
||||
PMMR::at(&mut self.output_pmmr_h.backend, self.output_pmmr_h.last_pos);
|
||||
output_pmmr.merkle_proof(pos)
|
||||
}
|
||||
|
||||
/// Compact the MMR data files and flush the rm logs
|
||||
pub fn compact(&mut self) -> Result<(), Error> {
|
||||
let commit_index = self.commit_index.clone();
|
||||
|
||||
Reference in New Issue
Block a user