一、密码学相关资料

使用Bouncy Castle生成数字签名、数字信封

ECDH and ECDSA(ECC椭圆曲线算法3)

数字签名算法RSA与 ECDSA的比较与分析

Java密码学 非对称加密以及使用secp256k1进行数字签名(ECDSA),也适合Android(上)

外国程序员大佬教你做一个——“Bitcoin(比特币)”的工作库

ASN.1概述及数据类型详解

ASN.1笔记——标准编码规则BER

二、第三方类库

<dependency>
<groupId>com.madgag.spongycastle</groupId>
<artifactId>core</artifactId>
<version>1.52.0.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>25.0-jre</version>
</dependency>

三、源码摘要说明

PeerGroup--->Peer--->Wallet(CoinSelector ,KeyChainGroup,KeyChain ,ECKey , KeyCrypter)

--->Transaction--->Block--->BlockChain

org.bitcoinj.core.NetworkParameters:

public static final int TARGET_TIMESPAN = 14 * 24 * 60 * 60;  // 2 weeks per difficulty cycle, on average.
public static final int TARGET_SPACING = 10 * 60; // 10 minutes per block.
public static final int INTERVAL = TARGET_TIMESPAN / TARGET_SPACING; /**
* The maximum number of coins to be generated
*/
public static final long MAX_COINS = 21000000;

createGenesis - 创世区块

org.bitcoinj.core.AbstractBitcoinNetParams

public static final int REWARD_HALVING_INTERVAL = 210000;//奖励减半周期

isRewardHalvingPoint

isDifficultyTransitionPoint

checkDifficultyTransitions

org.bitcoinj.core.Block:

solve - 挖矿算法

checkProofOfWork - 工作量证明算法

getDifficultyTargetAsInteger - 获取区块难度目标

    /** Height of the first block */
public static final int BLOCK_HEIGHT_GENESIS = 0;//The genesis block has a height of zero.
/**
* <p>A utility method that calculates how much new Bitcoin would be created by the block at the given height.
* The inflation of Bitcoin is predictable and drops roughly every 4 years (210,000 blocks). At the dawn of
* the system it was 50 coins per block, in late 2012 it went to 25 coins per block, and so on. The size of
* a coinbase transaction is inflation plus fees.</p>
*
* <p>The half-life is controlled by {@link org.bitcoinj.core.NetworkParameters#getSubsidyDecreaseBlockCount()}.
* </p>
*/
public Coin getBlockInflation(int height) {
return FIFTY_COINS.shiftRight(height / params.getSubsidyDecreaseBlockCount());
}
    /**
* Returns the work represented by this block.<p>
*
* Work is defined as the number of tries needed to solve a block in the
* average case. Consider a difficulty target that covers 5% of all possible
* hash values. Then the work of the block will be 20. As the target gets
* lower, the amount of work goes up.
*/
public BigInteger getWork() throws VerificationException {
BigInteger target = getDifficultyTargetAsInteger();
return LARGEST_HASH.divide(target.add(BigInteger.ONE));
}

org.bitcoinj.core.AbstractBlockChain:

OrphanBlock:孤块

// 将区块加入到区块链中

private boolean add(Block block, boolean tryConnecting,
@Nullable List<Sha256Hash> filteredTxHashList, @Nullable Map<Sha256Hash, Transaction> filteredTxn)
throws BlockStoreException, VerificationException, PrunedException {
//......
// Try linking it to a place in the currently known blocks. if (storedPrev == null) {
// We can't find the previous block. Probably we are still in the process of downloading the chain and a
// block was solved whilst we were doing it. We put it to one side and try to connect it later when we
// have more blocks.
checkState(tryConnecting, "bug in tryConnectingOrphans");
log.warn("Block does not connect: {} prev {}", block.getHashAsString(), block.getPrevBlockHash());
orphanBlocks.put(block.getHash(), new OrphanBlock(block, filteredTxHashList, filteredTxn));
return false;
} else {
checkState(lock.isHeldByCurrentThread());
// It connects to somewhere on the chain. Not necessarily the top of the best known chain.
params.checkDifficultyTransitions(storedPrev, block, blockStore);
connectBlock(block, storedPrev, shouldVerifyTransactions(), filteredTxHashList, filteredTxn);
}
//...... }

tryConnectingOrphans - 孤块处理

org.bitcoinj.core.Peer:

processMessage - 消息处理

org.bitcoinj.wallet.Wallet:

1、变量定义

2、构造函数

3、私钥管理 - Key Management

4、序列化支持 - Serialization support

5、Inbound transaction reception and processing

6、Event listeners

7、Vending transactions and other internal state

8、Balance and balance futures

9、Creating and sending transactions

10、Reorganisations

11、Bloom filtering

12、Extensions to the wallet format

13、Fee calculation code

14、Wallet maintenance transactions

最新文章

  1. 【Java EE 学习 20】【使用过滤器实现登陆验证、权限认证】【观察者模式和监听器(使用监听器实现统计在线IP、登录IP 、踢人功能)】
  2. NGUI 基础知识
  3. 10.python之socket和socketserver
  4. python基础(set)补充
  5. MySQL数据库获取汉字拼音的首字母函数
  6. current online redo logfile 丢失的处理方法
  7. 创建TabBar
  8. Redis初体验
  9. ③bootstrap文本使用基础案例
  10. Laravel学习笔记(三)--在CentOS上配置Laravel
  11. Delphi做验证码登录窗口
  12. ZIP、tar.gz压缩时排除指定目录
  13. 稀疏矩阵 part 5
  14. 推荐 3 篇关于 java8 Lambda表达式的文章
  15. python 转义字符 html 爬虫
  16. is_null, empty, isset的区别
  17. [剑指Offer]39-数组中出现次数超过一半的数字(快排延申,找第k大数同理)
  18. CentOS 6.9/7通过yum安装指定版本的Node.js
  19. ES6 import 循环加载
  20. 那些原生的javascript APIs

热门文章

  1. Linux内核编译与安装
  2. SQL 中的多条件查询
  3. CorelCAD for Mac(绘图设计软件)破解版安装
  4. R语言手册
  5. SNF.CodeGenerator代码生成器前夕-代码生成器初始配置
  6. Java compiler level does not match the version of the installed Java project facet解决办法
  7. 100种不同图片切换效果插件pageSwitch
  8. Ubuntu下的Wine&amp;WineQQ
  9. android 自定义无限循环播放的viewPager。轮播ViewPager。实现循环播放 广告,主题内容,活动,新闻内容时。
  10. jquery 选择对象随心所欲,遍历数组更是易如反掌