9 - PrivateKeys - 用私钥签名发送交易

使用私钥对交易进行签名处理,并且发送交易。

前期准备,向指定的账户地址 转入适当的测试代币 1BTC

mg1ZAJirgGotuBhoFVjnpJhYtQTvmxFJRn

Status: 0/unconfirmed, in memory pool
Date: 2019/8/15 09:54
To: 08-15-001 mg1ZAJirgGotuBhoFVjnpJhYtQTvmxFJRn
Debit: -1.00000000 BTC
Transaction fee: -0.00003360 BTC
Net amount: -1.00003360 BTC
Transaction ID: bd5b0f4bbdb477b1f73c18256114c7fcf80a07f85f25739c3f72a5d7e66c6420
Transaction total size: 249 bytes
Transaction virtual size: 168 bytes
Output index: 0

执行generate 6
转账:向mjFV5huR6ArRzzMP7ZPMYsEL5pQ54ULxKQ转账0.8 BTC
修改对应参数,并执行方法;
日志

Address from private key is: mg1ZAJirgGotuBhoFVjnpJhYtQTvmxFJRn
Aug 15, 2019 9:59:18 AM org.bitcoinj.core.Context getOrCreate
WARNING: Implicitly creating context. This is a migration step and this message will eventually go away.
Aug 15, 2019 9:59:18 AM org.bitcoinj.core.Context <init>
INFO: Creating bitcoinj 0.16-SNAPSHOT context.
Aug 15, 2019 9:59:18 AM org.bitcoinj.crypto.MnemonicCode toSeed
INFO: PBKDF2 took 231.7 ms
Aug 15, 2019 9:59:19 AM org.bitcoinj.core.AbstractBlockChain <init>
INFO: chain head is at height 0:
block:
hash: 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206
version: 1
previous block: 0000000000000000000000000000000000000000000000000000000000000000
time: 1296688602 (2011-02-02T23:16:42Z)
difficulty target (nBits): 545259519
nonce: 2

Aug 15, 2019 9:59:19 AM org.bitcoinj.core.PeerGroup8 run INFO: Starting ... Aug 15, 2019 9:59:19 AM org.bitcoinj.core.PeerGroup6 go
INFO: Localhost peer detected, trying to use it instead of P2P discovery
Aug 15, 2019 9:59:19 AM org.bitcoinj.core.PeerGroup connectTo
INFO: Attempting connection to [127.0.0.1]:18444 (0 connected, 1 pending, 0 max)
Aug 15, 2019 9:59:19 AM org.bitcoinj.net.NioClientManager handleKey
INFO: Connected to localhost/127.0.0.1:18444
Aug 15, 2019 9:59:19 AM org.bitcoinj.core.Peer connectionOpened
INFO: Announcing to localhost/127.0.0.1:18444 as: /bitcoinj:0.16-SNAPSHOT/
Aug 15, 2019 9:59:19 AM org.bitcoinj.core.Peer processVersionMessage
INFO: Peer{[127.0.0.1]:18444, version=70015, subVer=/Satoshi:0.17.1/, services=1037 (NETWORK, BLOOM, WITNESS, NETWORK_LIMITED), time=2019-08-15 09:59:19, height=613}
Aug 15, 2019 9:59:19 AM org.bitcoinj.core.PeerGroup handleNewPeer
INFO: Peer{[127.0.0.1]:18444, version=70015, subVer=/Satoshi:0.17.1/, services=1037 (NETWORK, BLOOM, WITNESS, NETWORK_LIMITED), time=2019-08-15 09:59:19, height=613}: New peer (1 connected, 0 pending, 1 max)
Aug 15, 2019 9:59:19 AM org.bitcoinj.core.PeerGroup setDownloadPeer
INFO: Setting download peer: Peer{[127.0.0.1]:18444, version=70015, subVer=/Satoshi:0.17.1/, services=1037 (NETWORK, BLOOM, WITNESS, NETWORK_LIMITED), time=2019-08-15 09:59:19, height=613}
Aug 15, 2019 9:59:19 AM org.bitcoinj.core.listeners.DownloadProgressTracker startDownload
INFO: Downloading block chain of size 613.


INFO: Received tx for 1.00 BTC: bd5b0f4bbdb477b1f73c18256114c7fcf80a07f85f25739c3f72a5d7e66c6420 [1] in block 71afe4afe3e28ad2e23e0005d864fee90a0097f1513b416f579a732c62f0525a
Aug 15, 2019 9:59:19 AM org.bitcoinj.wallet.Wallet processTxFromBestChain
INFO: tx bd5b0f4bbdb477b1f73c18256114c7fcf80a07f85f25739c3f72a5d7e66c6420 ->unspent
Aug 15, 2019 9:59:19 AM org.bitcoinj.wallet.Wallet receive
INFO: Balance is now: 1.00 BTC
Aug 15, 2019 9:59:19 AM org.bitcoinj.core.AbstractBlockChain tryConnectingOrphans
INFO: Connected orphan 4f5e03f4517e066c48bf31dd993688978f16a5ad698e87aa6f1227b487ee2d11
Aug 15, 2019 9:59:19 AM org.bitcoinj.core.AbstractBlockChain tryConnectingOrphans
INFO: Connected 1 orphan blocks.
Aug 15, 2019 9:59:19 AM org.bitcoinj.core.listeners.DownloadProgressTracker progress
INFO: Chain download 100% done with 0 blocks to go, block date 2019-08-15T01:58:51Z
Claiming 1.00 BTC
Aug 15, 2019 9:59:19 AM org.bitcoinj.wallet.Wallet completeTx
INFO: Completing send tx with 1 outputs totalling 0.80 BTC and a fee of 0.001 BTC/vkB
Aug 15, 2019 9:59:19 AM org.bitcoinj.wallet.DeterministicKeyChain maybeLookAhead
INFO: 1 keys needed for M/0H/1 = 1 issued + 0 lookahead size + 0 lookahead threshold - 0 num children
Aug 15, 2019 9:59:19 AM org.bitcoinj.wallet.DeterministicKeyChain maybeLookAhead
INFO: Took 1.218 ms
Aug 15, 2019 9:59:19 AM org.bitcoinj.wallet.Wallet completeTx
INFO: with 0.199773 BTC change
Aug 15, 2019 9:59:19 AM org.bitcoinj.wallet.Wallet completeTx
INFO: completed: Transaction{86c0d3110fb15fb0518286f3d5daf6e03b655692bdc58e614372b9e7c2dffa1a
weight: 900 wu, 225 bytes
purpose: USER_PAYMENT
in PUSHDATA(71)[30440220407e159b585289908e9315bd3a4a49751874c73277a89f609ddb265029e360b002203885600407306dcfa2610b18109183f185988449de6443fd44ad2820b137365701] PUSHDATA(33)[02abc6ecceae5a6487a38551d69aed5b631229d7919ea5442df8ec0949115987bf] 1.00 BTC
P2PKH addr:mg1ZAJirgGotuBhoFVjnpJhYtQTvmxFJRn outpoint:bd5b0f4bbdb477b1f73c18256114c7fcf80a07f85f25739c3f72a5d7e66c6420:0
out DUP HASH160 PUSHDATA(20)[5b76039c649c75b878fae8c7cc97a9a500760454] EQUALVERIFY CHECKSIG 0.199773 BTC
P2PKH addr:morZAGsDS6cDb5KbYFvm87noXMghvgoSkx
out DUP HASH160 PUSHDATA(20)[28f38c2ab536ad0e4e5d2602297d8d73633f78cc] EQUALVERIFY CHECKSIG 0.80 BTC
P2PKH addr:mjFV5huR6ArRzzMP7ZPMYsEL5pQ54ULxKQ
fee 0.00025222 BTC/wu, 0.00100888 BTC/kB 0.000227 BTC
}


INFO: Stopping ...
Aug 15, 2019 9:59:24 AM org.bitcoinj.core.PeerGroup setDownloadPeer
INFO: Unsetting download peer: Peer{[127.0.0.1]:18444, version=70015, subVer=/Satoshi:0.17.1/, services=1037 (NETWORK, BLOOM, WITNESS, NETWORK_LIMITED), time=2019-08-15 09:59:19, height=613}

执行交易 generate 6
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,444评论 6 496
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,421评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,036评论 0 349
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,363评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,460评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,502评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,511评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,280评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,736评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,014评论 2 328
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,190评论 1 342
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,848评论 5 338
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,531评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,159评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,411评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,067评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,078评论 2 352

推荐阅读更多精彩内容