Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ビットコイン トランザクション色々
Search
suish
July 18, 2017
Technology
1
2.5k
ビットコイン トランザクション色々
トランザクション構造と生トランザクション P2PKHのトランザクション署名検証
suish
July 18, 2017
Tweet
Share
Other Decks in Technology
See All in Technology
abema-trace-sampling-observability-cost-optimization
tetsuya28
0
410
ソースを読む時の思考プロセスの例-MkDocs
sat
PRO
1
350
[re:Inent2025事前勉強会(有志で開催)] re:Inventで見つけた人生をちょっと変えるコツ
sh_fk2
1
1.1k
境界線が消える世界におけるQAエンジニアのキャリアの可能性を考える / Considering the Career Possibilities for QA Engineers
mii3king
2
110
文字列操作の達人になる ~ Kotlinの文字列の便利な世界 ~ - Kotlin fest 2025
tomorrowkey
2
310
ざっくり学ぶ 『エンジニアリングリーダー 技術組織を育てるリーダーシップと セルフマネジメント』 / 50 minute Engineering Leader
iwashi86
8
4k
仕様駆動開発を実現する上流工程におけるAIエージェント活用
sergicalsix
10
5.1k
次世代のメールプロトコルの斜め読み
hirachan
1
190
マルチエージェントのチームビルディング_2025-10-25
shinoyamada
0
240
AWS DMS で SQL Server を移行してみた/aws-dms-sql-server-migration
emiki
0
270
어떤 개발자가 되고 싶은가?
arawn
1
360
OPENLOGI Company Profile for engineer
hr01
1
46k
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
174
15k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Thoughts on Productivity
jonyablonski
71
4.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Music & Morning Musume
bryan
46
6.9k
Code Reviewing Like a Champion
maltzj
526
40k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
The Pragmatic Product Professional
lauravandoore
36
7k
It's Worth the Effort
3n
187
28k
The Cult of Friendly URLs
andyhume
79
6.6k
Transcript
1
0. 1. 2. 3. 4. P2PKH 5. ※ segwit Tx
2
@sarmases 1 Bitcoin/Ethereum/Rootstock Scala 3
4
? (1/2) Bitcoin ( ) 5
? (2/2) 6
7
4bytes 0x01000000(1 ) Input 1-9bytes(VarInt) 0x02(1 ) Input Output 1-9bytes(VarInt)
0x02(1 ) Output 4bytes 0x00000000 ※ 5 (0x1DCD6500) 0 8
TxID 32bytes UTXO Index 4bytes 0x01000000 Unlocking Script 1-9bytes(VarInt) 0x6B
Unlocking Script 4bytes 0xFFFFFFFF ※ Tx Tx 0xFFFFFFFF 9
8bytes 0x01000000 Locking Script 1-9bytes(VarInt) 0x02 Locking Script satoshi 1satoshi
10
VarInt < 0xFD 1bytes (uint8_t) <= 0xFFFF 3bytes 0xFD 2bytes
(uint16_t) <= 0xFFFF FFFF 5bytes 0xFE 4bytes (uint32_t) <= 0xFFFF FFFF FFFF FFFF 9bytes 0xFF 8bytes (uint64_t) 5 => 0x05 255 => 0xFDFF00 11
( ) TxID Little Endian Big Endian 1 0x01 0x01
65536 0x010000 0x000001 0xF778C5D33453 0x5334D3C578F7 0xF778C5D33453 12
13
TxID( ID) Tx hash256(SHA-256 ) 0100000001c9e72944b5fd2b195085f9e8852e96181b4d4ce4a4b8cd993e 6d7925a0ce1c9b000000006946304302202173dc799db6b7b93b1f9b53f7 74c95aedc57dbe6a4d496bfd78d1e4b220c2db021f67e18545d2eccf7f56 2c8ec71f91e718d2292702aeb880a1d95f44fb8a66ab0121029700d3ba67 e374c699c4e5992a2f69f8a8e9321cefadae0c69eb56dba73d30e2ffffff
ff02f3653a01000000001976a9148e92fcfd113418f75356c5ca77b4463d 1bc099d288ace0673500000000001976a9144fcc9445c2edb970cb1ad427 0dc42b392596176188ac00000000 14
(1/2) Unlocking Script Locking Script 01000000 // 00000001 01 //Input
-c9e72944b5fd2b195085f9e8852e96181b4d4ce4a4b8cd993e6d7925a0ce 1c9b //TxID 00000000 // 69 // Unlocking Script 105bytes 46304302202173dc799db6b7b93b1f9b53f774c95aedc57dbe6a4d496bfd 78d1e4b220c2db021f67e18545d2eccf7f562c8ec71f91e718d2292702ae b880a1d95f44fb8a66ab0121029700d3ba67e374c699c4e5992a2f69f8a8 e9321cefadae0c69eb56dba73d30e2 // ffffffff // 15
(2/2) 02 //Output -f3653a0100000000 // 0x013a65f3 20604403satoshi(0.20604403BTC) 19 //Locking Script
25bytes 76a9148e92fcfd113418f75356c5ca77b4463d1bc099d288ac //Locking Script -e067350000000000 // 0x3567e0 3500000satoshi(0.035BTC) 19 //Locking Script 25bytes 76a9144fcc9445c2edb970cb1ad4270dc42b392596176188ac //Locking Script 00000000 // 16
46 //70bytes PUSH 304302202173dc79...fb8a66ab01 // 21 // 33bytes PUSH 029700d3ba0c69eb...dba73d30e2
// - 0x01- 0x4b PUSH OP_PUSHDATA1 0x4c 1byte PUSH OP_PUSHDATA2 0x4d 2bytes PUSH OP_PUSHDATA4 0x4e 4bytes PUSH 17
76 //OP_DUP a9 //OP_HASH160 14 //20bytes PUSH 8e92fcfd113418f75356c5ca77b4463d1bc099d2//20bytes 88 //OP_EQUALVERIFY
ac //OP_CHECKSIG OP_DUP OP_HASH160 HASH160 OP_EQUALVERIFY OP_CHECKSIG ( ) 1 PUSH 0 PUSH 18
( ) (1/6) 1(True) Tx UTXO 76a914/*899ee4cb09de33f6d7a91827ffdf45d28be998d5*/88ac PUSH (P2PKH) {DATA}
{DATA} OP_DUP OP_HASH160 {DATA} OP_EQUALVERIFY OP_CHECKSIG 1 OK 19
( ) (2/6) /* Unlocking Script */ 46 //70bytes PUSH
3043022...a1d95f44fb8a66ab01 // 21 //33bytes PUSH 029700...e0c69eb56dba73d30e2 // /* Locking Script ( TxID Output Index ) */ 76 //OP_DUP a9 //OP_HASH160 14 //20bytes PUSH 899ee4cb...ffdf45d28be998d5 // HASH160 ( ) 88 //OP_EQUALVERIFY ac //OP_CHECKSIG [ ] // PUSH [ , ] // PUSH [ , , ] // [ , , HASH] // HASH160 [ , , HASH, HASH] // HASH PUSH [ , ] // HASH 20
( ) (3/6) Bitcoin HASH256 (Sig Hash ) 1byte Sig
Hash 21
( ) (4/6) Code SIGHASH_ALL 0x01 Unlocking Script SIGHASH_NONE 0x02
SIGHASH_SINGLE 0x03 SIGHASH_ANYONECANPAY 0x80 ( ) 22
( ) (5/6) OP_CHECKSIG 01 SIGHASH_ALL Tx Hash Type 4bytes
//SigHash Tx 01000000 // 00000001 01 //Input -c9e72944b5fd2b19508...925a0ce1c9b //TxID 00000000 // 19 // Unlocking Script 76a914899ee4cb09de33f6d7a91827ffdf45d28be998d588ac //00 OR Input LockingScript ffffffff // 23
( ) (6/6) Tx HASH256 (ECDSA Secp256k1) 1 0 PUSH
[1] [0] 02 -f3653a0100000000 // 0x013a65f3 20604403satoshi(0.206 19 //Locking Script 25bytes 76a9148e92fcfd113418f75356c5ca77b4463d1bc099d288ac //Locking -e067350000000000 // 0x3567e0 3500000satoshi(0.035BTC) 19 //Locking Script 25bytes 76a9144fcc9445c2edb970cb1ad4270dc42b392596176188ac //Locking 00000000 // 01000000 // SigHash Type 01 SIGHASH_ALL 24
25
Tx TxID ( ) Mt.Gox TxID Sig Hash Type Locking
Script ECDSA (ECDSA s + - ) DATAPUSH 26
- PUSHDATA - 0x01-0x4b PUSH OP_PUSHDATA1 0x4c 1byte PUSH OP_PUSHDATA2
0x4d 2bytes PUSH OP_PUSHDATA4 0x4e 4bytes PUSH PUSHDATA Tx 27
Tx 46 (76bytes PUSH) 3043022...66ab01 ( ) 21 (33bytes PUSH)
029700d...3d30e2 ( ) 4c46 (OP_PUSHDATA1 76bytes PUSH) 3043022...66ab01 ( ) 21 (33bytes PUSH) 029700d...3d30e2 ( ) 1byte Tx TxID 7ba53ceea57f5554a266e0ea8b6ac2a772d5bf81c3753e501be9b95f31d654ea ↓ 7374e545e77f380efe21c0d1808c548b42096c5230c204ce1b5df79b8c836b66 28
P2PKH ( ) TxID ( ) segwit SigHash BIP143 29