【发布时间】:2022-01-15 09:03:35
【问题描述】:
有人可以帮我创建一个伪代码来显示比特币如何防止双花吗? 这是我的代码(在https://www.sofi.com/ 的帮助下):
This program is to prevent double-spending:
Person A and Person B go to a store with only one collective BTC to spend.
Person A buys a TV costing exactly 1 BTC.
Person B buys a motorcycle that also costs exactly 1 BTC.
blockchain = []
pool_of_unconfirmed_transactions = []
Both transactions go into a pool of unconfirmed transactions:
pool_of_unconfirmed_transactions.append(person A buys)
pool_of_unconfirmed_transactions.append(person B buys)
only the first transaction gets confirmations
and is verified by miners in the next block.
If person A buys == first buyer:
person A's transaction == valid
blockchain.append(person A's transaction)
del mem_pool[person B's transaction]
else:
person B's transaction == valid
del mem_pool[person A's transaction]
Whichever transaction gets the maximum number of network confirmations
(typically a minimum of six) will be included in the blockchain,
while others are discarded.
Once confirmations and transactions are put on the blockchain
they are time-stamped, rendering them irreversible and impossible to alter.
没事吧? 有什么建议吗?
【问题讨论】:
标签: python security pseudocode bitcoin