Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Index your code
hub
/
github.com/dukedaily/go-bitcoin-demo
/ functions
Functions
50 in github.com/dukedaily/go-bitcoin-demo
⨍
Functions
50
◇
Types & classes
11
↓ 5 callers
Function
isValidAddress
(address string)
wallet.go:108
↓ 4 callers
Function
GetBlockChainInstance
获取区块链实例,用于后续操作, 每一次有业务时都会调用
blockchain.go:70
↓ 4 callers
Method
NewIterator
将Iterator绑定到BlockChain
blockchain.go:156
↓ 4 callers
Method
Next
给Iterator绑定一个方法:Next 1. 返回当前所指向的区块 2. 向左移动(指向前一个区块)
blockchain.go:168
↓ 4 callers
Method
setHash
# 获取交易ID 对交易做哈希处理
transaction.go:51
↓ 4 callers
Function
uintToByte
(num uint64)
utils.go:10
↓ 3 callers
Function
NewWalletManager
创建walletManager结构
walletmanager.go:25
↓ 3 callers
Function
getPubKeyHashFromPubKey
给定公钥,得到公钥哈希值
wallet.go:72
↓ 3 callers
Method
isCoinbaseTx
判断一笔交易是否为挖矿交易
transaction.go:99
↓ 3 callers
Function
isFileExist
判断文件是否存在
utils.go:24
↓ 3 callers
Function
newTXOutput
由于没有办法直接将地址赋值给TXoutput,所以需要提供一个output的方法
transaction.go:39
↓ 2 callers
Method
FindMyUTXO
获取指定地址的金额,实现遍历账本的通用函数 给定一个地址,返回所有的utxo
blockchain.go:207
↓ 2 callers
Function
NewBlock
创建一个区块(提供一个方法) 输入:数据,前区块的哈希值 输出:区块
block.go:45
↓ 2 callers
Function
NewCoinbaseTx
# 创建挖矿交易
transaction.go:73
↓ 2 callers
Function
NewProofOfWork
创建ProofOfWork block由用户提供 target目标值由系统提供
proofofwork.go:29
↓ 2 callers
Method
PrepareData
拼接nonce和block数据
proofofwork.go:82
↓ 2 callers
Method
Serialize
绑定Serialize方法, gob编码
block.go:76
↓ 2 callers
Function
checkSum
得到4字节的校验码
wallet.go:100
↓ 2 callers
Method
findTransaction
(txid []byte)
blockchain.go:381
↓ 2 callers
Function
getPubKeyHashFromAddress
通过地址,反推出公钥哈希,注意不是公钥
wallet.go:85
↓ 2 callers
Method
trimmedCopy
trim修剪, 签名和校验时都会使用
transaction.go:247
↓ 1 callers
Method
AddBlock
提供一个向区块链中添加区块的方法
blockchain.go:109
↓ 1 callers
Function
CreateBlockChain
用于访问bolt数据库,得到最好一个区块的哈希值 创建区块,从无到有:这个函数仅执行一次
blockchain.go:25
↓ 1 callers
Function
Deserialize
反序列化,输入[]byte,返回block
block.go:92
↓ 1 callers
Method
HashTransactionMerkleRoot
简易梅克尔根,把所有的交易拼接到一起,做哈希处理,最终赋值给block.MerKleRoot
block.go:108
↓ 1 callers
Method
IsValid
()
proofofwork.go:100
↓ 1 callers
Function
NewTransaction
创建普通交易 1. from/*付款人*/,to/*收款人*/,amount输入参数/*金额*/
transaction.go:110
↓ 1 callers
Method
Run
挖矿函数,不断变化nonce,使得sha256(数据+nonce) < 难度值 返回:区块哈希,nonce
proofofwork.go:47
↓ 1 callers
Method
Run
const Usage1 = "" + "./block" + "" 负责解析命令的方法
cli.go:33
↓ 1 callers
Method
addBlock
(data string)
commandline.go:5
↓ 1 callers
Method
createBlockChain
(address string)
commandline.go:16
↓ 1 callers
Method
createWallet
()
walletmanager.go:41
↓ 1 callers
Method
createWallet
()
commandline.go:148
↓ 1 callers
Method
findNeedUTXO
输入:地址,金额 返回:map[string][]int, float64
blockchain.go:297
↓ 1 callers
Method
getAddress
- ==根据私钥生成地址==
wallet.go:54
↓ 1 callers
Method
getBalance
(address string)
commandline.go:68
↓ 1 callers
Method
listAddress
()
commandline.go:164
↓ 1 callers
Method
listAddresses
()
walletmanager.go:121
↓ 1 callers
Method
loadFile
读取wallet.dat文件,加载wm中
walletmanager.go:95
↓ 1 callers
Function
newWalletKeyPair
- ==创建秘钥对==
wallet.go:33
↓ 1 callers
Method
print
()
commandline.go:30
↓ 1 callers
Method
printTx
()
commandline.go:177
↓ 1 callers
Method
saveFile
()
walletmanager.go:67
↓ 1 callers
Method
send
(from, to string, amount float64, miner, data string)
commandline.go:99
↓ 1 callers
Method
sign
实现具体签名动作(copy,设置为空,签名动作) 参数1:私钥 参数2:inputs所引用的output所在交易的集合: > key :交易id > value:交易本身
transaction.go:194
↓ 1 callers
Method
signTransaction
签名函数
blockchain.go:327
↓ 1 callers
Method
verify
具体校验
transaction.go:269
↓ 1 callers
Method
verifyTransaction
校验单笔交易
blockchain.go:352
Method
String
()
transaction.go:319
Function
main
()
main.go:3