Skip to Content
밑바닥부터 시작하는 비트코인
book

밑바닥부터 시작하는 비트코인

by 류정필, 송재준
November 2019
Beginner to intermediate
408 pages
9h 29m
Korean
Hanbit Media, Inc.
Content preview from 밑바닥부터 시작하는 비트코인
5
트랜잭션
155
5.6
트랜잭션 직렬화 코딩하기
지금까지 직렬화된 트랜잭션을 파싱했습니다. 이제 반대의 경우, 즉 주어진 트랜잭션을 직렬화
하는 방법을 살펴보겠습니다. 먼저
TxOut
클래스부터 시작합니다.
class TxOut:
...
def serialize(self):
'''Returns the byte serialization of the transaction output'''
result = int_to_little_endian(self.amount, 8)
result += self.script_pubkey.serialize()
return result
TxOut
객체를
bytes
형으로 직렬화합니다.
다음은
TxIn
을 직렬화합니다.
class TxIn:
...
def serialize(self):
'''Returns the byte serialization of the transaction input'''
result = self.prev_tx[::-1]
result += int_to_little_endian(self.prev_index, 4)
result += self.script_sig.serialize()
result += int_to_little_endian(self.sequence, 4)
return result
마지막으로
Tx
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

밑바닥부터 시작하는 딥러닝

밑바닥부터 시작하는 딥러닝

사이토 고키
실리콘밸리 리더십

실리콘밸리 리더십

김정혜, 마이클 롭

Publisher Resources

ISBN: 9791162248294