// Path: core/src/main/java/com/google/bitcoin/params/TestNet3Params.java
// public class TestNet3Params extends NetworkParameters {
//     public TestNet3Params() {
//         super();
//         id = ID_TESTNET;
//         // Genesis hash is a0d810b45c92ac12e8c5b312a680caafba52216e5d9649b9dd86f7ad6550a43f
//         packetMagic = 0xfcc1b7dc; // correspond to pchMessageStart in main.cpp
//         interval = INTERVAL;
//         digishieldInterval = DIGISHIELD_INTERVAL;
//         
//         //switchKGWBlock = 0;
//         //switchDigishieldBlock = 300;
//         switchKGWBlock = SWITCH_KGW_BLOCK;
//         switchDigishieldBlock = SWITCH_DIGISHIELD_BLOCK;
//         // switchDGWV3Block = SWITCH_DGW_V3_BLOCK;
//         // switchAlgoLyra2ReV2 = SWITCH_ALGO_LYRA2_RE_V2;
//         switchDGWV3Block = 5;
//         switchAlgoLyra2ReV2 = 5;
//         
//         targetTimespan = TARGET_TIMESPAN;
//         digishieldTargetTimespan = DIGISHIELD_TARGET_TIMESPAN;
//         proofOfWorkLimit = Utils.decodeCompactBits(0x1e0fffffL);
//         port = 19401;
//         addressHeader = 111;
//         p2shHeader = 196;
//         acceptableAddressCodes = new int[] { addressHeader, p2shHeader };
//         dumpedPrivateKeyHeader = 239;
//         genesisBlock.setTime(1388479759L);
//         genesisBlock.setDifficultyTarget(0x1e0ffff0L);
//         genesisBlock.setNonce(600389L);
//         spendableCoinbaseDepth = 100;  // equivalent to COINBASE_MATURITY ?
//         subsidyDecreaseBlockCount = 1051200;
// 
//         String genesisHash = genesisBlock.getHashAsString();
//         // a0d810b45c92ac12e8c5b312a680caafba52216e5d9649b9dd86f7ad6550a43f
//         checkState(genesisHash.equals("a0d810b45c92ac12e8c5b312a680caafba52216e5d9649b9dd86f7ad6550a43f"));
//         alertSigningKey = Hex.decode("04887665070e79d20f722857e58ec8f402733f710135521a0b63441419bf5665ba4623bed13fca0cb2338682ab2a54ad13ce07fbc81c3c2f0912a4eb8521dd3cfb");
// 
//         dnsSeeds = new String[] {
//                 "test-dnsseed.monacoin.org",
//         };
//     }
// 
//     private static TestNet3Params instance;
//     public static synchronized TestNet3Params get() {
//         if (instance == null) {
//             instance = new TestNet3Params();
//         }
//         return instance;
//     }
// 
//     public String getPaymentProtocolId() {
//         return PAYMENT_PROTOCOL_ID_TESTNET;
//     }
// }
// 
// Path: core/src/main/java/com/google/bitcoin/store/MemoryBlockStore.java
// public class MemoryBlockStore implements BlockStore {
//     private LinkedHashMap<Sha256Hash, StoredBlock> blockMap = new LinkedHashMap<Sha256Hash, StoredBlock>() {
//         @Override
//         protected boolean removeEldestEntry(Map.Entry<Sha256Hash, StoredBlock> eldest) {
//             return blockMap.size() > 60 * 60 * 24 * 7 / NetworkParameters.TARGET_SPACING + 1; // KGW past block max
//         }
//     };
//     private StoredBlock chainHead;
// 
//     public MemoryBlockStore(NetworkParameters params) {
//         // Insert the genesis block.
//         try {
//             Block genesisHeader = params.getGenesisBlock().cloneAsHeader();
//             StoredBlock storedGenesis = new StoredBlock(genesisHeader, genesisHeader.getWork(), 0);
//             put(storedGenesis);
//             setChainHead(storedGenesis);
//         } catch (BlockStoreException e) {
//             throw new RuntimeException(e);  // Cannot happen.
//         } catch (VerificationException e) {
//             throw new RuntimeException(e);  // Cannot happen.
//         }
//     }
// 
//     public synchronized void put(StoredBlock block) throws BlockStoreException {
//         if (blockMap == null) throw new BlockStoreException("MemoryBlockStore is closed");
//         Sha256Hash hash = block.getHeader().getHash();
//         blockMap.put(hash, block);
//     }
// 
//     public synchronized StoredBlock get(Sha256Hash hash) throws BlockStoreException {
//         if (blockMap == null) throw new BlockStoreException("MemoryBlockStore is closed");
//         return blockMap.get(hash);
//     }
// 
//     public StoredBlock getChainHead() throws BlockStoreException {
//         if (blockMap == null) throw new BlockStoreException("MemoryBlockStore is closed");
//         return chainHead;
//     }
// 
//     public void setChainHead(StoredBlock chainHead) throws BlockStoreException {
//         if (blockMap == null) throw new BlockStoreException("MemoryBlockStore is closed");
//         this.chainHead = chainHead;
//     }
//     
//     public void close() {
//         blockMap = null;
//     }
// }


import com.google.bitcoin.core.*;
import com.google.bitcoin.params.TestNet3Params;
import com.google.bitcoin.store.BlockStore;
import com.google.bitcoin.store.MemoryBlockStore;
import java.io.File;
import java.math.BigInteger;
import java.net.InetAddress;
/*
 * Copyright 2011 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.bitcoin.examples;



/**
 * RefreshWallet loads a wallet, then processes the block chain to update the transaction pools within it.
 */
public class RefreshWallet {
    public static void main(String[] args) throws Exception {
        File file = new File(args[0]);
        Wallet wallet = Wallet.loadFromFile(file);
        System.out.println(wallet.toString());

        // Set up the components and link them together.
// Path: core/src/main/java/com/google/bitcoin/params/TestNet3Params.java
// public class TestNet3Params extends NetworkParameters {
//     public TestNet3Params() {
//         super();
//         id = ID_TESTNET;
//         // Genesis hash is a0d810b45c92ac12e8c5b312a680caafba52216e5d9649b9dd86f7ad6550a43f
//         packetMagic = 0xfcc1b7dc; // correspond to pchMessageStart in main.cpp
//         interval = INTERVAL;
//         digishieldInterval = DIGISHIELD_INTERVAL;
//         
//         //switchKGWBlock = 0;
//         //switchDigishieldBlock = 300;
//         switchKGWBlock = SWITCH_KGW_BLOCK;
//         switchDigishieldBlock = SWITCH_DIGISHIELD_BLOCK;
//         // switchDGWV3Block = SWITCH_DGW_V3_BLOCK;
//         // switchAlgoLyra2ReV2 = SWITCH_ALGO_LYRA2_RE_V2;
//         switchDGWV3Block = 5;
//         switchAlgoLyra2ReV2 = 5;
//         
//         targetTimespan = TARGET_TIMESPAN;
//         digishieldTargetTimespan = DIGISHIELD_TARGET_TIMESPAN;
//         proofOfWorkLimit = Utils.decodeCompactBits(0x1e0fffffL);
//         port = 19401;
//         addressHeader = 111;
//         p2shHeader = 196;
//         acceptableAddressCodes = new int[] { addressHeader, p2shHeader };
//         dumpedPrivateKeyHeader = 239;
//         genesisBlock.setTime(1388479759L);
//         genesisBlock.setDifficultyTarget(0x1e0ffff0L);
//         genesisBlock.setNonce(600389L);
//         spendableCoinbaseDepth = 100;  // equivalent to COINBASE_MATURITY ?
//         subsidyDecreaseBlockCount = 1051200;
// 
//         String genesisHash = genesisBlock.getHashAsString();
//         // a0d810b45c92ac12e8c5b312a680caafba52216e5d9649b9dd86f7ad6550a43f
//         checkState(genesisHash.equals("a0d810b45c92ac12e8c5b312a680caafba52216e5d9649b9dd86f7ad6550a43f"));
//         alertSigningKey = Hex.decode("04887665070e79d20f722857e58ec8f402733f710135521a0b63441419bf5665ba4623bed13fca0cb2338682ab2a54ad13ce07fbc81c3c2f0912a4eb8521dd3cfb");
// 
//         dnsSeeds = new String[] {
//                 "test-dnsseed.monacoin.org",
//         };
//     }
// 
//     private static TestNet3Params instance;
//     public static synchronized TestNet3Params get() {
//         if (instance == null) {
//             instance = new TestNet3Params();
//         }
//         return instance;
//     }
// 
//     public String getPaymentProtocolId() {
//         return PAYMENT_PROTOCOL_ID_TESTNET;
//     }
// }
// 
// Path: core/src/main/java/com/google/bitcoin/store/MemoryBlockStore.java
// public class MemoryBlockStore implements BlockStore {
//     private LinkedHashMap<Sha256Hash, StoredBlock> blockMap = new LinkedHashMap<Sha256Hash, StoredBlock>() {
//         @Override
//         protected boolean removeEldestEntry(Map.Entry<Sha256Hash, StoredBlock> eldest) {
//             return blockMap.size() > 60 * 60 * 24 * 7 / NetworkParameters.TARGET_SPACING + 1; // KGW past block max
//         }
//     };
//     private StoredBlock chainHead;
// 
//     public MemoryBlockStore(NetworkParameters params) {
//         // Insert the genesis block.
//         try {
//             Block genesisHeader = params.getGenesisBlock().cloneAsHeader();
//             StoredBlock storedGenesis = new StoredBlock(genesisHeader, genesisHeader.getWork(), 0);
//             put(storedGenesis);
//             setChainHead(storedGenesis);
//         } catch (BlockStoreException e) {
//             throw new RuntimeException(e);  // Cannot happen.
//         } catch (VerificationException e) {
//             throw new RuntimeException(e);  // Cannot happen.
//         }
//     }
// 
//     public synchronized void put(StoredBlock block) throws BlockStoreException {
//         if (blockMap == null) throw new BlockStoreException("MemoryBlockStore is closed");
//         Sha256Hash hash = block.getHeader().getHash();
//         blockMap.put(hash, block);
//     }
// 
//     public synchronized StoredBlock get(Sha256Hash hash) throws BlockStoreException {
//         if (blockMap == null) throw new BlockStoreException("MemoryBlockStore is closed");
//         return blockMap.get(hash);
//     }
// 
//     public StoredBlock getChainHead() throws BlockStoreException {
//         if (blockMap == null) throw new BlockStoreException("MemoryBlockStore is closed");
//         return chainHead;
//     }
// 
//     public void setChainHead(StoredBlock chainHead) throws BlockStoreException {
//         if (blockMap == null) throw new BlockStoreException("MemoryBlockStore is closed");
//         this.chainHead = chainHead;
//     }
//     
//     public void close() {
//         blockMap = null;
//     }
// }


// Path: examples/src/main/java/com/google/bitcoin/examples/RefreshWallet.java
import com.google.bitcoin.core.*;
import com.google.bitcoin.params.TestNet3Params;
import com.google.bitcoin.store.BlockStore;
import com.google.bitcoin.store.MemoryBlockStore;
import java.io.File;
import java.math.BigInteger;
import java.net.InetAddress;

/*
 * Copyright 2011 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.bitcoin.examples;



/**
 * RefreshWallet loads a wallet, then processes the block chain to update the transaction pools within it.
 */
public class RefreshWallet {
    public static void main(String[] args) throws Exception {
        File file = new File(args[0]);
        Wallet wallet = Wallet.loadFromFile(file);
        System.out.println(wallet.toString());

        // Set up the components and link them together.
        final NetworkParameters params = TestNet3Params.get();