無知

갈 길이 먼 공부 일기

기술 공부/블록체인

스마트 컨트랙트 (1) | Smart Contract & Bitcoin

moozii 2022. 4. 3. 18:50

1. 탈 중앙화의 흐름과 미래

우버와 같은 공유 경제, 플랫폼의 등장에 따라 많은 효익이 발생했지만, 한편으로는 그 운영 주체가 특정 기업인 것처럼 중앙화된 주체가 관리함으로써 다양한 문제가 발생한다. 예를 들어, 관리 주체의 부도덕함이 아래 사례처럼 드러나기도 한다. 

https://www.forbes.com/sites/kashmirhill/2014/10/03/god-view-uber-allegedly-stalked-users-for-party-goers-viewing-pleasure/?sh=3a24550a3141 

 

'God View': Uber Allegedly Stalked Users For Party-Goers' Viewing Pleasure (Updated)

At a launch party in Chicago, Uber allegedly treated guests to the whereabouts and movements of 30 "notable" Uber users in New York in real time without those users' permission.

www.forbes.com

 

 

따라서 블록체인이라는 기술을 통해, 관리 주체를 탈 중앙화시켜, 누구나 스마트 계약을 통해 해당 플랫폼을 구현/참여할 수 있도록 하는 움직임이 태동한 것이 지금에 이르렀다.

https://cointelegraph.com/news/arcade-city-decentralized-blockchain-based-answer-to-uber

 

Arcade City: Decentralized, Blockchain-Based Answer to Uber

Christopher David of Arcade City unveils a new decentralized, driver-controlled ride-sharing service.

cointelegraph.com

 

 

더 나아가서는, 마이크 헌이 주창하는 자율적 경제 주체에 대해서도 살펴볼 필요가 있다. 스마트 컨트랙트를 작성할 수 있는 지갑을 보유한 주체가 더이상 인간으로만 한정 지어지지 않고, 예를 들어 자율주행 자동차 그 자체가 독립적인 경제 주체가 되어 운영비를 지불하고 서비스를 제공하는 등의 경제 활동을 영위할 수 있는 미래를 상상해보는 것이다. 

Mike Hearn: Autonomous agents, self driving cars and Bitcoin

https://www.slideshare.net/mikehearn/future-of-money-26663148

 

Future of money

Slides for a talk on the future of money, at Turing Festival 2013.

www.slideshare.net

 

 

 

 

 

2. 스마트 컨트랙트와 이더리움

스마트 계약, 스마트 컨트랙트는 단순히 이야기하면, 계약의 신뢰성 보장, 중재, 실행, 분쟁 해결 등을 모두 프로그래밍화, 자동화한 형태의 계약을 의미한다고 생각한다. 그 원형은, 스마트 계약의 첫 주창자인 닉 자보의 아이디어를 더 살펴보면 자세히 알 수 있다. 

 

[Smart Contracts: Building Blocks for Digital Markets]

The contract, a set of promises agreed to in a "meeting of the minds", is the traditional way to formalize a relationship. While contracts are primarily used in business relationships (the focus of this article), they can also involve personal relationships such as marraiges. Contracts are also important in politics, not only because of "social contract" theories but also because contract enforcement has traditionally been considered a basic function of capitalist governments.

Whether enforced by a government, or otherwise, the contract is the basic building block of a free market economy. Over many centuries of cultural evolution has emerged both the concept of contract and principles related to it, encoded into common law. Algorithmic information theory suggests that such evolved structures are often prohibitively costly to recompute. If we started from scratch, using reason and experience, it could take many centuries to redevelop sophisticated ideas like property rights that make the modern free market work [Hayek].

The success of the common law of contracts, combined with the high cost of replacing it, makes it worthwhile to both preserve and to make use of these principles where appropriate. Yet, the digital revolution is radically changing the kinds of relationships we can have. What parts of our hard-won legal tradition will still be valuable in the cyberspace era? What is the best way to apply these common law principles to the design of our on-line relationships?

Computers make possible the running of algorithms heretofore prohibitively costly, and networks the quicker transmission of larger and more sophsiticated messages. Furthermore, computer scientists and cryptographers have recently discovered many new and quite interesting algorithms. Combining these messages and algorithms makes possible a wide variety of new protocols.

New institutions, and new ways to formalize the relationships that make up these institutions, are now made possible by the digital revolution. I call these new contracts "smart", because they are far more functional than their inanimate paper-based ancestors. No use of artificial intelligence is implied. A smart contract is a set of promises, specified in digital form, including protocols within which the parties perform on these promises.

@Nick Szabo -- Smart Contracts: Building Blocks for Digital Markets, 1996
http://www.truevaluemetrics.org/DBpdfs/BlockChain/Nick-Szabo-Smart-Contracts-Building-Blocks-for-Digital-Markets-1996-14591.pdf 

 

[Formalizing and Securing Relationships on Public Networks]

Smart contracts combine protocols, users interfaces, and promises expressed via those interfaces, to formalize and secure relationships over public networks. This gives us new ways to formalize the digital relationships which are far more functional than their inanimate paper-based ancestors. Smart contracts reduce mental and computational transaction costs, imposed by either principals, third parties, or their tools. Mark Miller[18] foresees that the law of the Internet, and the devices attached to it, will be provided by a grand merger of law and computer security. If so, smart contracts will be a major force behind this merger.

@Nick Szabo Originally published in 1997
https://bitcoinstan.io/prehistory/doc/1997_2.pdf 

 

 

 

그리고 이러한 스마트 계약은, 암호화폐라는 기술적 혁신을 통해 보다 그 의미를 꽃피울 수 있게 되었다. 스마트 컨트랙트의 이행과 관련해 경제적인 교환 재화가 필요할 때, 전통적인 은행 구좌 이용에는 한계가 있어도 지갑과 암호화폐를 활용한다면 가치의 이전까지도 구현이 가능하기 때문이다. 

 

스마트 컨트랙트 + 암호화폐의 융합을 불러일으킨 최초의 시도는 비탈릭 부테린이 설계한 이더리움이다.

 

[Ethereum: The Ultimate Smart Contract and Autonomous Corporation Platform on the Blockchain]

In the last few months, there has been a great amount of interest into the area of using the Bitcoin blockchain, the mechanism that allows for the entire world to agree on the state of a public ownership database, for more than just money. Perhaps the first, and oldest, such alternative application is colored coins, which is a protocol that allows users to label specific bitcoins and treat them as assets representing some real world value - whether company shares, collectibles or even existing currencies like gold and USD. A more independent alternative, Ripple, also includes the ability to create custom currencies and assets, but adds a decentralized exchange. More recently, Mastercoin has started to go even further, allowing more complex financial contracts such as hedging, trust-free dice rolls, binary options and self-stabilizing currencies - essentially, almost any common financial instrument imaginable. Taken together, all of these projects can be thought of as initial efforts toward a sort of "cryptocurrency 2.0" - they are to Bitcoin what Web 2.0 was to the World Wide Web circa 1995.

At the same time, there has been significant interest in "decentralized autonomous corporations" - autonomous entities that operate on the blockchain in a completely transparent and publicly managed way without any central control whatsoever. Rather than the relationships of the investors, owners and employees of the corporation being mediated by a legal contract or a set of organizational bylaws, the funds and corporate resources are managed directly on the blockchain. However, decentralized autonomous corporations are difficult to implement today, simply because the scripting systems of Bitcoin, and even proto-cryptocurrency 2.0 alternatives like Ripple and Mastercoin, are far too limited to allow the kind of arbitrarily complex computation that DACs require. Although these platforms have begun to offer increasingly complex contracts such as financial derivatives, order matching and trust-free bets, the way that the protocols are set up is inherently limited and closed-ended: each of these use cases is treated as a specific transaction type, not allowing any way for users to build contracts that the developers have not specifically chosen to include.

What this project intends to do is take cryptocurrency 2.0, and generalize it - create a fully-fledged, Turing-complete (but heavily fee-regulated) cryptographic ledger that allows participants to encode arbitrarily complex contracts, autonomous agents and relationships that will be mediated entirely by the blockchain. On-chain currencies, futures contracts, prediction markets, Namecoin-style domain name systems and even provably fair gambling sites will become trivial to implement, existing as simple, hundred-line-of-code contracts on the chain.

...

The Ethereum protocol's design philosophy is in many ways the opposite from that taken by many other cryptocurrencies today. Other cryptocurrencies aim to add complexity and increase the number of "features"; Ethereum, on the other hand, takes features away. The protocol does not "support" multisignature transactions, multiple inputs and outputs, hash codes, lock times or many other features that even Bitcoin provides. Instead, all complexity comes from an all-powerful, Turing-complete assembly language, which can be used to build up literally any feature that is mathematically describable. The language itself follows an Orwellian Newspeak principle; any instruction which can be replaced by a sequence of less than four other instructions has been removed. As a result, we have a cryptocurrency protocol whose codebase is very small, and yet which can do anything that any cryptocurrency will ever be able to do.

@Vitalik Buterin's website
https://web.archive.org/web/20131219030753/https:/vitalik.ca/ethereum.html 

 

 

 

 

 

3. 비트코인의 효용

(1) 사업체 입장

  • 기존 카드 결제 방식에 비해 더 저렴하다
    • 매출 2~3%에 해당하는 카드 수수료를 결제 과정의 중개 기관들에게 납부할 필요가 없이 상대적으로 저렴한 수수료를 기반으로 비트코인 네트워크에서 결제 내역을 승인한다
    • 중간자 비용에는 카드 가입비, 연회비, ATM 사용료, 이자 비용 등 시스템 내 비용 전체를 포괄한다
  • 기존 카드 결제 방식에 비해 더 빠르다
    • 중간자인 은행이 결제 요청 이상 여부를 검증하고 해당 구좌에서 결제액을 인출하는 데에 평균 3일 정도 걸리는 것에 반해 비트코인은 즉각 승인이 가능하다

 

 

(2) 사용자 입장

  • 비트코인은 기존 중앙화된 기관들의 리스크가 없는 새로운 형태의 안전자산이다
  • 저개발국가 및 시스템 소외자에게는 빈곤을 해결할 대안이다
  • 탈중앙화된 시스템 기반 응용프로그램의 시도가 가능하다
    • 비트코인 네트워크 상 새로운 서비스를 올릴 수 있다 (비트코인 네트워크의 블록 생성 및 합의 시스템을 기반으로 비트코인은 서비스 유통을 위한 수단에 불과. 비트코인 거래 내 정보를 기반으로 서비스를 운영)
    • 새로운 블록체인 네트워크를 만들어 서비스를 최적화할 수도 있다 (이더리움, 리플 등)

 

비트코인은 기존 중앙화된 기관들의 리스크가 없는 새로운 형태의 안전자산이다
[키프로스 위기로 가상화폐 '비트코인' 인기 절정]

키프로스 금융위기 사태로 온라인 공간에서 통용되는 가상화폐 `비트코인(Bitcoin)'과 실제 화폐인 미국 달러와의 교환 환율이 지난 두달 사이에 350% 이상 급등했다고 IT 전문매체인 씨넷이 29일 보도했다. 비트코인은 이달 초만 하더라도 지난 1월보다 가격이 두 배 오른 1비트코인당 40달러로 거래됐으나 키프로스 금융위기가 발생하면서 29일에는 1비트코인당 95달러에 거래됐다. 키프로스 정부가 구제금융을 받는 대가로 10만유로 이상의 고액 예금에 대한 헤어컷(손실)을 받아들임으로써 구제금융 과정에서 은행 예금도 떼일 수 있다는 불안감이 커지고 있기 때문이다. 금융시장 전문가인 니콜라스 콜라스는 "비트코인을 요구하는 수요가 키프로스 금융위기의 영향을 가장 많이 받는 그리스, 스페인 등에서 예금에 대한 과세 우려 때문에 증가하고 있다"면서 "구글에서 비트코인에 대한 검색도 지난 2011년 7월 이후 최고치를 기록하고 있다"고 말했다.

rhew@yna.co.kr, 2013-03-29, 연합신문
https://www.yna.co.kr/view/AKR20130329121000009 

 

저개발국가 및 시스템 소외자에게는 빈곤을 해결할 대안이다

비트페사(BitPesa)는 디지털 결제 플랫폼으로 아프리카 전역의 개인과 기관을 대상으로한 도매 암호화폐 유동성 제공업체이다. 케냐의 모든 모바일 머니 지갑으로 송금할 수 있는 서비스를 통해 베타 사이트를 시작했다. 설립자 및 대표는 엘리자베스 로시엘로(Elizabeth Rossiello)이다.
http://wiki.hash.kr/index.php/%EB%B9%84%ED%8A%B8%ED%8E%98%EC%82%AC 

“비트코인으로 저개발국 송금 혁신 꿈꾼다”
요한 바비 CEO가 말문을 열었다. “37코인스는 SMS를 보내듯 간단하게 비트코인을 주고받을 수 있는 비트코인 지갑입니다. 비트코인은 인터넷에 연결된 사람만 쓸 수 있죠. 하지만 전세계에는 은행계좌조차 없는 사람이 5~6억명에 달합니다. 인터넷은 말할 것도 없죠. 인터넷이나 은행 서비스의 혜택을 못 받는 저개발국 사람들에게 금융서비스를 제공하는데 비트코인을 쓰는 겁니다. 비트코인은 수단일 뿐이죠.”
“저개발국 개발지원 현장에서 사람들을 만나고 글로벌 송금에 문제가 많은 걸 알았어요. 현지 주민에게 ‘외국에서 일하는 남편이 돈을 어떻게 보내주냐’라고 물었더니 아는 사람에게 전해전해 준다는 거에요. 이건 너무 위험하잖아요. 돈을 갖다주는 사람이 빼돌릴 수도 있고 강도를 당할지도 모르죠. 그런데 이 사람들은 그런 식으로 밖에 못 하는 거예요. 출생신고서도 없는 사람들이 은행계좌를 갖고 있을 리 없으니까요. 이들이 사는 가난한 동네에는 웨스턴유니온 같은 송금업체도 없어요. 그런데 이 사람들이 피처폰은 다 갖고 있더라고요. 그래서 모바일 송금 서비스를 만들자는 생각을 했죠.”
https://www.bloter.net/newsView/blt201402090001 

 

 

 

 

 

4. 비트코인의 동작 원리

 

(1) 이중지불 문제와 분산 장부

The problem of course is the payee can't verify that one of the owners did not double-spend the coin. A common solution is to introduce a trusted central authority, or mint, that checks every transaction for double spending. After each transaction, the coin must be returned to the mint to issue a new coin, and only coins issued directly from the mint are trusted not to be double-spent. The problem with this solution is that the fate of the entire money system depends on the company running the mint, with every transaction having to go through them, just like a bank. We need a way for the payee to know that the previous owners did not sign any earlier transactions. For our purposes, the earliest transaction is the one that counts, so we don't care about later attempts to double-spend. The only way to confirm the absence of a transaction is to be aware of all transactions. In the mint based model, the mint was aware of all transactions and decided which arrived first. To accomplish this without a trusted party, transactions must be publicly announced [1], and we need a system for participants to agree on a single history of the order in which they were received. The payee needs proof that at the time of each transaction, the majority of nodes agreed it was the first received.

Bitcoin: A Peer-to-Peer Electronic Cash System @Satoshi Nakamoto
https://bitcoin.org/bitcoin.pdf 

누가 얼마를 보유했는지, 다른 사람이 화폐를 복사해서 두번 사용하는 등 이중지불의 문제는 없는지, 결제를 요청한 사람이 지불 능력이 충분한지 등, 과거 중앙 기구들이 해결하던 신뢰성 검증 문제를 블록체인 및 암호화폐 상에서도 해결할 필요가 있다. 중앙 기관의 정보 관리가 아닌, 비트코인 네트워크 상의 모두가 일치된 정보, 이른바 분산화된 거래 장부를 동일하게 지녀, 각자가 거래를 검증할 수 있도록 하여 문제를 해결한다. 

 

The steps to run the network are as follows:
1) New transactions are broadcast to all nodes.
2) Each node collects new transactions into a block.
3) Each node works on finding a difficult proof-of-work for its block.
4) When a node finds a proof-of-work, it broadcasts the block to all nodes.
5) Nodes accept the block only if all transactions in it are valid and not already spent.
6) Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash.

Nodes always consider the longest chain to be the correct one and will keep working on extending it. If two nodes broadcast different versions of the next block simultaneously, some nodes may receive one or the other first. In that case, they work on the first one they received, but save the other branch in case it becomes longer. The tie will be broken when the next proofof-work is found and one branch becomes longer; the nodes that were working on the other branch will then switch to the longer one.

Bitcoin: A Peer-to-Peer Electronic Cash System @Satoshi Nakamoto
https://bitcoin.org/bitcoin.pdf 
[How does a block chain prevent double-spending of Bitcoins?]

Imagine that you have 1 BTC and you attempt to spend it twice in two separate transactions. You could attempt to do this by sending the same BTC to two separate bitcoin wallet addresses. Both of these transactions will then go into the pool of unconfirmed transactions. The first transaction would be approved via the confirmation mechanism and then verified into the subsequent block. However, the second transaction would be recognized as invalid by the confirmation process and would not be verified. If both transactions are pulled from the pool for confirmation simultaneously, the transaction with the highest number of confirmations will be included in the blockchain, while the other one will be discarded.

While this effectively deals with the issue of double spending, it is not without its issues. For example, the intended recipient of the second (failed) transaction would not have part in the transaction itself failing, and yet that person would not receive the bitcoin they had anticipated. Many merchants wait for at least 6 confirmations of a transaction (meaning that six subsequent blocks of transactions were added to the blockchain after the transaction in question). At this point, the merchant can safely assume that the transaction is valid.

There remain other vulnerabilities in this system which could allow double-spend attacks to take place. For example, if an attacker is somehow able to control at least 51% of the has power of the network, they can commit double spending. If an attacker were somehow able to get control of this much computational power, they could reverse transactions and create a separate, private blockchain. However, the rapid growth of bitcoin has virtually insured that this type of attack is impossible.

Investopedia, By NATHAN REIFF Updated August 26, 2021 Reviewed by ERIKA RASURE
https://www.investopedia.com/ask/answers/061915/how-does-block-chain-prevent-doublespending-bitcoins.asp 

 

 

 

(2) 블록체인 이름의 유래

블록체인 네트워크 상의 재화 이동이나 스마트 컨트랙트의 이행 등을 트랜잭션이라고 한다. 이런 개별 트랜잭션을 모아 하나의 블록이 만들어지고, 그 블록들이 연쇄되어 하나의 체인을 이루는데, 그 형태를 본따 블록체인이라고 명명한다.

 

 

(3) 해시함수의 활용과 작업증명

Bitcoin: A Peer-to-Peer Electronic Cash System @ Satoshi Nakamoto

We define an electronic coin as a chain of digital signatures. Each owner transfers the coin to the next by digitally signing a hash of the previous transaction and the public key of the next owner and adding these to the end of the coin. A payee can verify the signatures to verify the chain of ownership.

...

The solution we propose begins with a timestamp server. A timestamp server works by taking a hash of a block of items to be timestamped and widely publishing the hash, such as in a newspaper or Usenet post [2-5]. The timestamp proves that the data must have existed at the time, obviously, in order to get into the hash. Each timestamp includes the previous timestamp in its hash, forming a chain, with each additional timestamp reinforcing the ones before it.

...

To implement a distributed timestamp server on a peer-to-peer basis, we will need to use a proofof-work system similar to Adam Back's Hashcash [6], rather than newspaper or Usenet posts. The proof-of-work involves scanning for a value that when hashed, such as with SHA-256, the hash begins with a number of zero bits. The average work required is exponential in the number of zero bits required and can be verified by executing a single hash.

Bitcoin: A Peer-to-Peer Electronic Cash System @Satoshi Nakamoto
https://bitcoin.org/bitcoin.pdf 

 

해시 값은 블록체인 장부 기록 내용의 위변조 방지를 위해 사용된다. 해시 함수를 활용해 입력 데이터에 매핑되는 해시값을 구하는데, 입력값을 찾기 어렵다는 해시 함수의 속성과, 수학적으로 입력값이 다르면 해시 값도 다를 확률이 높다는 점 때문이다. 

 

암호용 해시함수를 활용해 거래 내역 블록의 해시 값을 구하고, 그 다음 블록에서 이전 블록의 해시값을 참고하면서 연쇄적으로 블록의 체인을 만들게 된다. 따라서, 체인 중간에 입력값을 변조시키면, 그 입력값에 대한 해시값도 달라지게 되므로 값의 변경을 즉각 인지할 수 있다. 그리고 그에 연결된 체인 내 그 이후 블록들도 자연스레 연쇄적으로 이전 블록의 해시값을 참고한다는 속성에 따라 해시값이 바뀌게 된다. 

 

사용하는 암호용 해시함수는 SHA256이고 아래 사이트로 확인할 수 있다.

 

SHA256 Online

 

emn178.github.io

 

 

To implement a distributed timestamp server on a peer-to-peer basis, we will need to use a proofof-work system similar to Adam Back's Hashcash [6], rather than newspaper or Usenet posts. The proof-of-work involves scanning for a value that when hashed, such as with SHA-256, the hash begins with a number of zero bits. The average work required is exponential in the number of zero bits required and can be verified by executing a single hash.

For our timestamp network, we implement the proof-of-work by incrementing a nonce in the block until a value is found that gives the block's hash the required zero bits. Once the CPU effort has been expended to make it satisfy the proof-of-work, the block cannot be changed without redoing the work. As later blocks are chained after it, the work to change the block would include redoing all the blocks after it.

The proof-of-work also solves the problem of determining representation in majority decision making. If the majority were based on one-IP-address-one-vote, it could be subverted by anyone able to allocate many IPs. Proof-of-work is essentially one-CPU-one-vote. The majority decision is represented by the longest chain, which has the greatest proof-of-work effort invested in it. If a majority of CPU power is controlled by honest nodes, the honest chain will grow the fastest and outpace any competing chains. To modify a past block, an attacker would have to redo the proof-of-work of the block and all blocks after it and then catch up with and surpass the work of the honest nodes. We will show later that the probability of a slower attacker catching up diminishes exponentially as subsequent blocks are added.

To compensate for increasing hardware speed and varying interest in running nodes over time, the proof-of-work difficulty is determined by a moving average targeting an average number of blocks per hour. If they're generated too fast, the difficulty increases.

Bitcoin: A Peer-to-Peer Electronic Cash System @Satoshi Nakamoto
https://bitcoin.org/bitcoin.pdf 

 

위변조를 더욱 어렵게 하기 위해, 해시함수를 통해 해시 값을 구하는데 한가지 제한을 추가하는데, 일반적으로 일정 개수 이상의 0으로 시작하는 해시값이 나올때까지 연산을 해야만 검증으로 인정해주는 것이다. 입력값에 더불어 무작위값인 논스를 추가해, 논스를 계속 변경해가면서 해시값을 구하다, 일정 개수 이상의 0으로 시작한다는 조건을 만족하면 그 불록의 해시값으로 인정해주는 것이다. (논스란, 여기서만 임시적으로 사용되고 다른 곳에는 활용되지 않는다는 뜻을 담은 단어이다.)

 

그렇게 해시값을 일정 조건으로 만족하도록 연산을 해서 구해내는 과정을 작업증명이라고 한다. 

 

시스템 상 가장 긴 체인만을 옳은 블록체인으로 채택하기 때문에, 누군가 이전 블록을 위변조하려면, 비트코인 네트워크 전체의 과반을 점유해야만 정보 조작이 가능하다. 

 

 

 

 

 

5. 비트코인 트랜잭션

>>> rawtx = fetchtx('1ea0c78e5232dbfee226f034eb78890188b9d888ece6ed18f767528bd49a1dd6')
>>> deserialize(rawtx)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\user\PycharmProjects\pybitcointools\bitcoin\transaction.py", line 91, in deserialize
    "script": read_var_string(),
  File "C:\Users\user\PycharmProjects\pybitcointools\bitcoin\transaction.py", line 71, in read_var_string
    size = read_var_int()
  File "C:\Users\user\PycharmProjects\pybitcointools\bitcoin\transaction.py", line 61, in read_var_int
    val = from_byte_to_int(tx[pos[0]-1])

pybitcointools 기반 실습 중 위의 문제를 해결해보려 했으나..
오류가 지속되어 일단 넘어가기로 한다. 이론적 내용만 살펴보자.

 

트랜잭션 = Input + Output

  • Input Sum = Output Sum + Transaction Fee
  • 현재 트랜잭션의 인풋은 과거 트랜잭션의 아웃풋으로 구성
  • 이전의 트랜잭션 아웃풋 중 아직 인풋으로 활용되지 않은 것을, Unspent Transaction Output, UTXO라 부름
  • 비트코인 네트워크는 전체 시스템 내 사용 가능한 모든 UTXO를 UTXO Set으로 관리
  • 트랜잭션 스크립트 내 비트코인 단위는 사토시(s, Satoshi). 1 Bitcoin = 100mm Satoshi.

 

트랜잭션 아웃풋의 구성

  • value = 보내는 비트코인 양 (사토시 단위)
  • script = 보내는 전송 대상 (locking script로 기록된 scriptPubKey)

 

트랜잭션 인풋의 구성

  • 인풋은 사실상 어떤 UTXO를 사용할지 이를 가리키는 포인터
  • outpoint.hash = transaction ID, 어떤 거래의 UTXO를 사용할 것인지 명세하기 위핸 트랜잭션 해시값
  • outpoint.index = output index, 위의 거래의 몇번째 인덱스 상의 아웃풋으로 존재하는 UTXO를 사용할지
  • script = scriptSig, unlocking script로 자신이 해당 UTXO를 소유하고 있음을 증명
  • sequence = Sequence Number로 locktime에 사용됨 (추후 설명)