当前位置: 首页>>代码示例>>Java>>正文


Java Sha256Hash类代码示例

本文整理汇总了Java中com.google.bitcoin.core.Sha256Hash的典型用法代码示例。如果您正苦于以下问题:Java Sha256Hash类的具体用法?Java Sha256Hash怎么用?Java Sha256Hash使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Sha256Hash类属于com.google.bitcoin.core包,在下文中一共展示了Sha256Hash类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSet

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
public Set<Sha256Hash> getSet(Object key)
{
  while(true)
  {
    try
    {
      return tryGetSet(key);
    }
    catch(SQLException e)
    {
      e.printStackTrace();
      try{Thread.sleep(1000);}catch(Exception e2){}
    }

  }
}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:17,代码来源:SqlMapSet.java

示例2: JelectrumDBCloudData

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
public JelectrumDBCloudData(Config conf)
    throws Exception
{
    super(conf);

    conf.require("google_api_keyfile");
    conf.require("google_api_account");
    conf.require("google_project");

    ds = DatastoreFactory.get().create(getDatastoreOptions().build());

    openStorage();

    String file_base = conf.get("db_direct_path");

    tx_map = new DatastoreMap<Sha256Hash, SerializedTransaction>(ds,bigstore,"tx_map");
    address_to_tx_map = new DatastoreMap<String, HashSet<Sha256Hash> >(ds,bigstore,"address_to_tx_map");
    //block_store_map = new DatastoreMap<Sha256Hash, StoredBlock>(ds,bigstore,"block_store_map");
    block_store_map = new DirectFileMap<Sha256Hash, StoredBlock>(file_base,"block_store_map",4);
    special_block_store_map = new DatastoreMap<String, StoredBlock>(ds,bigstore,"special_block_store_map");
    block_map = new DatastoreMap<Sha256Hash, SerializedBlock>(ds,bigstore,"block_map");
    tx_to_block_map = new DatastoreMap<Sha256Hash, HashSet<Sha256Hash> >(ds,bigstore,"tx_to_block_map");

}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:25,代码来源:JelectrumDBCloudData.java

示例3: JelectrumDBDirect

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
public JelectrumDBDirect(Config conf)
    throws java.io.IOException
{
    super(conf);

    conf.require("db_direct_path");

    String base = conf.get("db_direct_path");
    tx_map = new DirectFileMap<Sha256Hash, SerializedTransaction>(base,"tx_map",4);

    address_to_tx_map = new DirectFileMap<String, HashSet<Sha256Hash> >(base,"address_to_tx_map", 4);
    block_store_map = new DirectFileMap<Sha256Hash, StoredBlock>(base,"block_store_map",4);
    special_block_store_map = new DirectFileMap<String, StoredBlock>(base,"special_block_store_map",4);
    block_map = new DirectFileMap<Sha256Hash, SerializedBlock>(base,"block_map",4);
    tx_to_block_map = new DirectFileMap<Sha256Hash, HashSet<Sha256Hash> >(base,"tx_to_block_map",4);

}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:18,代码来源:JelectrumDBDirect.java

示例4: reDownloadBlockTransactions

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
public void reDownloadBlockTransactions(Integer blockHeight) {
	Database db = Database.getInstance();
	ResultSet rs = db.executeQuery("select * from blocks where block_index='"+blockHeight.toString()+"';");
	try {
		if (rs.next()) {
			Block block = peerGroup.getDownloadPeer().getBlock(new Sha256Hash(rs.getString("block_hash"))).get();
			db.executeUpdate("delete from transactions where block_index='"+blockHeight.toString()+"';");
			Integer txSnInBlock=0;
			for (Transaction tx : block.getTransactions()) {
				importTransaction(tx,txSnInBlock, block, blockHeight);
				txSnInBlock++;
			}
		}
	} catch (Exception e) {

	}
}
 
开发者ID:newbiecoin,项目名称:newbiecoinj,代码行数:18,代码来源:Blocks.java

示例5: testEcKeySign

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
@Test
public void testEcKeySign() {

	String password = "pass1234";
	String challenge = "challenge1234";

	byte[] secretTarget = Utils.doubleDigest(password.getBytes());
	ECKey key = new ECKey(new BigInteger(1, secretTarget), null, true);
	ECDSASignature sign = key.sign(Sha256Hash.createDouble(challenge
			.getBytes()));
	assertNotNull(sign);
	System.out.println("sign.r=" + sign.r);
	System.out.println("sign.s=" + sign.s);
	String signHex = BaseEncoding.base16().encode(sign.encodeToDER());
	System.out.println(signHex);

	byte[] sign2byte = BaseEncoding.base16().decode(signHex);
	ECDSASignature signTarget = ECDSASignature.decodeFromDER(sign2byte);
	assertFalse(ECKey.verify(
			Sha256Hash.createDouble("FakeChallenge".getBytes()).getBytes(),
			signTarget, key.getPubKey()));
	assertTrue(ECKey.verify(Sha256Hash.createDouble(challenge.getBytes())
			.getBytes(), signTarget, key.getPubKey()));

}
 
开发者ID:y12studio,项目名称:bkbc-tools,代码行数:26,代码来源:MainPrivKeyShareTest.java

示例6: addAll

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
public void addAll(Collection<Map.Entry<K,Sha256Hash>> lst)
{
  while(true)
  {
    try
    {
      tryAddAll(lst);
      return;
    }
    catch(SQLException e)
    {
      e.printStackTrace();
      try{Thread.sleep(1000);}catch(Exception e2){}
    }

  }


}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:20,代码来源:SqlMapSet.java

示例7: MainNetParams

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
public MainNetParams() {
    super();
    interval = INTERVAL;
    targetTimespan = TARGET_TIMESPAN;
    proofOfWorkLimit = Utils.decodeCompactBits(0x1d00ffffL);
    dumpedPrivateKeyHeader = 128;
    addressHeader = 0;
    p2shHeader = 5;
    acceptableAddressCodes = new int[] { addressHeader, p2shHeader };
    port = 8333;
    packetMagic = 0xf9beb4d9L;
    genesisBlock.setDifficultyTarget(0x1d00ffffL);
    genesisBlock.setTime(1231006505L);
    genesisBlock.setNonce(2083236893);
    id = ID_MAINNET;
    subsidyDecreaseBlockCount = 210000;
    spendableCoinbaseDepth = 100;
    String genesisHash = genesisBlock.getHashAsString();
    checkState(genesisHash.equals("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"),
            genesisHash);

    // This contains (at a minimum) the blocks which are not BIP30 compliant. BIP30 changed how duplicate
    // transactions are handled. Duplicated transactions could occur in the case where a coinbase had the same
    // extraNonce and the same outputs but appeared at different heights, and greatly complicated re-org handling.
    // Having these here simplifies block connection logic considerably.
    checkpoints.put(91722, new Sha256Hash("00000000000271a2dc26e7667f8419f2e15416dc6955e5a6c6cdf3f2574dd08e"));
    checkpoints.put(91812, new Sha256Hash("00000000000af0aed4792b1acee3d966af36cf5def14935db8de83d6f9306f2f"));
    checkpoints.put(91842, new Sha256Hash("00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec"));
    checkpoints.put(91880, new Sha256Hash("00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721"));
    checkpoints.put(200000, new Sha256Hash("000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf"));

    dnsSeeds = new String[] {
            "seed.bitcoin.sipa.be",        // Pieter Wuille
            "dnsseed.bluematt.me",         // Matt Corallo
            "dnsseed.bitcoin.dashjr.org",  // Luke Dashjr
            "seed.bitcoinstats.com",       // Chris Decker
    };
}
 
开发者ID:10xEngineer,项目名称:My-Wallet-Android,代码行数:39,代码来源:MainNetParams.java

示例8: run

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
public void run()
{
  rnd = new Random();
  String key = "k-" + rnd.nextLong();

  byte[] b = new byte[32];
  rnd.nextBytes(b);
  Sha256Hash hash = new Sha256Hash(b);
  map.add(key, hash);

  sem.release();
  
}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:14,代码来源:SqlTest.java

示例9: addTxsToBlockMap

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
public final void addTxsToBlockMap(Collection<Sha256Hash> txs, Sha256Hash block)
{
  LinkedList<Map.Entry<Sha256Hash, Sha256Hash>> lst = new LinkedList<>();
  for(Sha256Hash tx : txs)
  {
    lst.add(new SimpleEntry<Sha256Hash, Sha256Hash>(tx, block));
    addTxToBlockMap(tx, block);
  }
  addTxsToBlockMap(lst);
}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:11,代码来源:JelectrumDB.java

示例10: toMnemonic

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
/**
 * Convert entropy data to mnemonic word list.
 */
public List<String> toMnemonic(byte[] entropy) throws MnemonicException.MnemonicLengthException {
    if (entropy.length % 4 > 0)
        throw new MnemonicException.MnemonicLengthException("entropy length not multiple of 32 bits");

    // We take initial entropy of ENT bits and compute its
    // checksum by taking first ENT / 32 bits of its SHA256 hash.

    byte[] hash = Sha256Hash.create(entropy).getBytes();
    boolean[] hashBits = bytesToBits(hash);
    
    boolean[] entropyBits = bytesToBits(entropy);
    int checksumLengthBits = entropyBits.length / 32;

    // We append these bits to the end of the initial entropy. 
    boolean[] concatBits = new boolean[entropyBits.length + checksumLengthBits];
    System.arraycopy(entropyBits, 0, concatBits, 0, entropyBits.length);
    System.arraycopy(hashBits, 0, concatBits, entropyBits.length, checksumLengthBits);

    // Next we take these concatenated bits and split them into
    // groups of 11 bits. Each group encodes number from 0-2047
    // which is a position in a wordlist.  We convert numbers into
    // words and use joined words as mnemonic sentence.

    ArrayList<String> words = new ArrayList<String>();
    int nwords = concatBits.length / 11;
    for (int i = 0; i < nwords; ++i) {
        int index = 0;
        for (int j = 0; j < 11; ++j) {
            index <<= 1;
            if (concatBits[(i * 11) + j])
                index |= 0x1;
        }
        words.add(this.wordList.get(index));
    }
        
    return words;        
}
 
开发者ID:cannabiscoindev,项目名称:cannabiscoinj,代码行数:41,代码来源:MnemonicCode.java

示例11: addAddressesToTxMap

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
public final void addAddressesToTxMap(Collection<String> addresses, Sha256Hash hash)
{
  LinkedList<Map.Entry<String, Sha256Hash>> lst = new LinkedList<>();

  for(String a : addresses)
  {
    lst.add(new SimpleEntry<String, Sha256Hash>(a, hash));
  }
  addAddressesToTxMap(lst);
}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:11,代码来源:JelectrumDB.java

示例12: MainNetParams

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
public MainNetParams() {
    super();
    interval = INTERVAL;
    targetTimespan = TARGET_TIMESPAN;
    proofOfWorkLimit = Utils.decodeCompactBits(0x1d00ffffL);
    dumpedPrivateKeyHeader = 128;
    addressHeader = 0;
    p2shHeader = 5;
    acceptableAddressCodes = new int[] { addressHeader, p2shHeader };
    port = 8333;
    packetMagic = 0xf9beb4d9L;
    genesisBlock.setDifficultyTarget(0x1d00ffffL);
    genesisBlock.setTime(1231006505L);
    genesisBlock.setNonce(2083236893);
    id = ID_MAINNET;
    subsidyDecreaseBlockCount = 210000;
    spendableCoinbaseDepth = 100;
    String genesisHash = genesisBlock.getHashAsString();
    checkState(genesisHash.equals("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"),
            genesisHash);

    // This contains (at a minimum) the blocks which are not BIP30 compliant. BIP30 changed how duplicate
    // transactions are handled. Duplicated transactions could occur in the case where a coinbase had the same
    // extraNonce and the same outputs but appeared at different heights, and greatly complicated re-org handling.
    // Having these here simplifies block connection logic considerably.
    checkpoints.put(91722, new Sha256Hash("00000000000271a2dc26e7667f8419f2e15416dc6955e5a6c6cdf3f2574dd08e"));
    checkpoints.put(91812, new Sha256Hash("00000000000af0aed4792b1acee3d966af36cf5def14935db8de83d6f9306f2f"));
    checkpoints.put(91842, new Sha256Hash("00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec"));
    checkpoints.put(91880, new Sha256Hash("00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721"));
    checkpoints.put(200000, new Sha256Hash("000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf"));

    dnsSeeds = new String[] {
            "seed.bitcoin.sipa.be",        // Pieter Wuille
            "dnsseed.bluematt.me",         // Matt Corallo
            "dnsseed.bitcoin.dashjr.org",  // Luke Dashjr
            "seed.bitcoinstats.com",       // Chris Decker
            "seed.bitnodes.io",            // Addy Yeow
    };
}
 
开发者ID:coinspark,项目名称:sparkbit-bitcoinj,代码行数:40,代码来源:MainNetParams.java

示例13: TestNet3Params

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
public TestNet3Params() {
    super();
    id = ID_TESTNET;

    // Genesis hash is 000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943

    packetMagic = 0x0b110907;
    interval = INTERVAL;
    targetTimespan = TARGET_TIMESPAN;
    proofOfWorkLimit = Utils.decodeCompactBits(0x1d00ffffL);
    port = 18333;
    addressHeader = CoinDefinition.testnetAddressHeader;
    p2shHeader = CoinDefinition.testnetp2shHeader;
    acceptableAddressCodes = new int[] { addressHeader, p2shHeader };
    dumpedPrivateKeyHeader = 128 + CoinDefinition.testnetAddressHeader;
    genesisBlock.setTime(CoinDefinition.testnetGenesisBlockTime);
    genesisBlock.setDifficultyTarget(CoinDefinition.testnetGenesisBlockDifficultyTarget);
    genesisBlock.setNonce(CoinDefinition.testnetGenesisBlockNonce);
    genesisBlock.setVersion(112);

    spendableCoinbaseDepth = 100;
    subsidyDecreaseBlockCount = CoinDefinition.subsidyDecreaseBlockCount;
    genesisBlock.setMerkleRoot(new Sha256Hash("868b2fb28cb1a0b881480cc85eb207e29e6ae75cdd6d26688ed34c2d2d23c776"));
    String genesisHash = genesisBlock.getHashAsString();
    if(CoinDefinition.supportsTestNet)
        checkState(genesisHash.equals(CoinDefinition.testnetGenesisHash));
    alertSigningKey = Hex.decode(CoinDefinition.TESTNET_SATOSHI_KEY);

    dnsSeeds = CoinDefinition.testnetDnsSeeds;

}
 
开发者ID:HashEngineering,项目名称:quarkcoinj,代码行数:32,代码来源:TestNet3Params.java

示例14: MainNetParams

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
public MainNetParams() {
    super();
    interval = INTERVAL;
    targetTimespan = TARGET_TIMESPAN;
    proofOfWorkLimit = CoinDefinition.proofOfWorkLimit;
    dumpedPrivateKeyHeader = 128 + CoinDefinition.AddressHeader;
    addressHeader = CoinDefinition.AddressHeader;
    p2shHeader = CoinDefinition.p2shHeader;
    acceptableAddressCodes = new int[] { addressHeader, p2shHeader};

    port = CoinDefinition.Port;
    packetMagic = CoinDefinition.PacketMagic;
    genesisBlock.setDifficultyTarget(CoinDefinition.genesisBlockDifficultyTarget);
    genesisBlock.setTime(CoinDefinition.genesisBlockTime);
    genesisBlock.setNonce(CoinDefinition.genesisBlockNonce);
    genesisBlock.setVersion(112);

    id = ID_MAINNET;
    subsidyDecreaseBlockCount = CoinDefinition.subsidyDecreaseBlockCount;
    spendableCoinbaseDepth = CoinDefinition.spendableCoinbaseDepth;
    genesisBlock.setMerkleRoot(new Sha256Hash("868b2fb28cb1a0b881480cc85eb207e29e6ae75cdd6d26688ed34c2d2d23c776"));
    String genesisHash = genesisBlock.getHashAsString();
    log.info("Genesis Block (complete): " + genesisBlock.toString()) ;
    checkState(genesisHash.equals(CoinDefinition.genesisHash),
            genesisHash);

    CoinDefinition.initCheckpoints(checkpoints);

    dnsSeeds = CoinDefinition.dnsSeeds;

}
 
开发者ID:HashEngineering,项目名称:quarkcoinj,代码行数:32,代码来源:MainNetParams.java

示例15: MainNetParams

import com.google.bitcoin.core.Sha256Hash; //导入依赖的package包/类
public MainNetParams() {
    super();
    interval = INTERVAL;
    targetTimespan = TARGET_TIMESPAN;
    proofOfWorkLimit = Utils.decodeCompactBits(0x1d00ffffL);
    acceptableAddressCodes = new int[] { 0 };
    dumpedPrivateKeyHeader = 128;
    addressHeader = 0;
    port = 8333;
    packetMagic = 0xf9beb4d9L;
    genesisBlock.setDifficultyTarget(0x1d00ffffL);
    genesisBlock.setTime(1231006505L);
    genesisBlock.setNonce(2083236893);
    id = ID_MAINNET;
    subsidyDecreaseBlockCount = 210000;
    spendableCoinbaseDepth = 100;
    String genesisHash = genesisBlock.getHashAsString();
    checkState(genesisHash.equals("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"),
            genesisHash);

    // This contains (at a minimum) the blocks which are not BIP30 compliant. BIP30 changed how duplicate
    // transactions are handled. Duplicated transactions could occur in the case where a coinbase had the same
    // extraNonce and the same outputs but appeared at different heights, and greatly complicated re-org handling.
    // Having these here simplifies block connection logic considerably.
    checkpoints.put(91722, new Sha256Hash("00000000000271a2dc26e7667f8419f2e15416dc6955e5a6c6cdf3f2574dd08e"));
    checkpoints.put(91812, new Sha256Hash("00000000000af0aed4792b1acee3d966af36cf5def14935db8de83d6f9306f2f"));
    checkpoints.put(91842, new Sha256Hash("00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec"));
    checkpoints.put(91880, new Sha256Hash("00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721"));
    checkpoints.put(200000, new Sha256Hash("000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf"));

    dnsSeeds = new String[] {
            "seed.bitcoin.sipa.be",        // Pieter Wuille
            "dnsseed.bluematt.me",         // Matt Corallo
            "dnsseed.bitcoin.dashjr.org",  // Luke Dashjr
    };
}
 
开发者ID:sserrano44,项目名称:bitcoinj-watcher-service,代码行数:37,代码来源:MainNetParams.java


注:本文中的com.google.bitcoin.core.Sha256Hash类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。