简体   繁体   English

确认比特币交易

[英]Confirm bitcoin transaction

I'm new at Blockchain development and I need to verify that some amount of BTC has been sent from address a to address b. 我是区块链开发的新手,我需要验证从地址a到地址b已发送了一定数量的BTC。 I'm calling Blockchain api , and browsing for transactions of the receiver address. 我正在调用Blockchain api ,并浏览接收方地址的交易。 The thing that confuses me is that in some cases there are multiple addresses in inputs. 让我感到困惑的是,在某些情况下,输入中有多个地址。 So how can I be sure that the one address I'm looking for sent the required amount? 那么,如何确定我要查找的那个地址发送了所需的金额? Also about transactions, can on BTC transaction hold multiple 'real' transactions? 关于交易,在BTC交易中能否持有多个“真实”交易? Thanks 谢谢

Probably better off asked on bitcoin.se but every bitcoin transaction may have multiple inputs and outputs. 关于bitcoin.se的询问可能要好一些,但每个比特币交易都可能有多个输入和输出。 If your wallet has 3 addresses to which 0.5 btc has been sent and not spent, and you then send 1.25 btc somewhere then all 3 of those 0.5 btc unspent transaction outputs will be used to build the 1.25 plus a new address for the 0.25 change. 如果您的钱包有3个发送了0.5 btc且未使用的地址,然后又将1.25 btc发送到某处,则这0.5 btc未使用的交易输出中的所有3个将用于构建1.25以及0.25更改的新地址。 The sending wallet will also own the address to which 0.25 in change was sent. 发送钱包也将拥有0.25零钱发送到的地址。 In this way a single btc wallet can end up owning millions of addresses 这样,单个btc钱包最终可以拥有数百万个地址

In practice it's quite likely that the total you send will be composed of multiple inputs so if you're trying to prove you send your grandma 1.25 BTC you don't look in transaction X inputs for your single address that originated 1.25, you look in tran X outputs for your grandma's address that received a total of 1.25. 实际上,您发送的总数很有可能由多个输入组成,因此,如果您想证明您发送了1.25 BTC的祖母,那么您不会在交易X输入中查找源自1.25的单个地址,而是查看您奶奶地址的tran X输出总共收到1.25。 Bear in mind that in this day and age of multiple output transactions your btc transaction might cite 100 outputs, 12 of which are grandma's address and which add up to 1.25 btc 请记住,在当今这样一个多输出交易的时代,您的btc交易可能会引用100个输出,其中12个是祖母的地址,总计1.25个btc

Yes, one btc transaction can hold tens or more payments to tens or more different individuals 是的,一次btc交易可以向数十个或更多不同的个人持有数十笔或更多笔款项


Edit in response to comment #1: 根据评论1进行编辑:

There might be any number of outputs, it's totally down to your wallet how it decides to send them out. 可能有任意数量的输出,这完全取决于您决定如何将其发送出去的钱包。 Remember that if the inputs don't add up to the outputs then just like buying a packet of gum with a twenty dollar note, there will be some change. 记住,如果输入的总和不等于输出的总和,就像买一包二十美元的口香糖,情况就会有所变化。 When you look at the transaction on a block explorer that your wallet built, there might be 100 inputs, 100 outputs (if you had a lot of people to pay) and even multiple changes if multiple inputs were split and sent back to yourself. 当您在钱包构建的区块浏览器上查看交易时,可能会有100个输入,100个输出(如果您要支付很多人的话),如果拆分了多个输入并将其发还给您自己,则可能会有多个更改。 If you think of your wallet bitcoin balance like blocks of cheese in the delicatessen, they all weigh different things, 3 people come and all want different amounts, the deli server person might get 6 blocks of cheese, have to cut them and combine them in different ways multiple times, then hand them over. 如果您将钱包中的比特币余额想像成熟食店中的奶酪块,它们的重量各不相同,三个人来了,都想要不同的金额,那么熟食店服务员可能会得到6块奶酪,必须将其切碎并合并在一起多次重复,然后移交给他们。 They don't necessarily become recombined either; 它们也不一定要重组。 people might walk away with multiple little bits of cheese making the total amount they wanted, and then if they want to give that cheese as gifts, they subdivide it.. Ultimately subdivision of cheese continues until all you end up with are crumbs, that cannot be transacted because putting them all in one transaction makes the transaction too big (kilobytes) for the network to allow, so you might engage in an exercise of consolidating them; 人们可能会放弃使用多个零碎的奶酪,制作出他们想要的总量,然后如果要把该奶酪作为礼物送给他们,那么就细分它。.最终,奶酪的细分一直持续到您最终得到的都是面包屑,进行事务处理是因为将它们全部放入一个事务中会使事务太大(千字节),网络无法承受,因此您可能需要进行合并这些事务的练习; sending them to yourself in exact multiples so no subdivision occurs. 将它们以精确的倍数发送给自己,因此不会发生细分。 Thus they become big lumps of cheese again. 因此,它们又变成了一大块奶酪。 If you hear people talking about wallets being dusty, it means they're tracking large numbers of tiny amounts - dust. 如果您听到人们谈论钱包里满是灰尘,那意味着他们正在追踪大量的微小物品-灰尘。

I think I understand the confusion now though; 我想我现在已经明白了困惑。 If two people agree to buy something from you for 5 BTC, one sends you 5 but the other is dishonest and only sends you 1. These may occur in the same block, but they wouldn't occur in the same transaction because they originated from different wallets. 如果两个人同意以5 BTC的价格从您那里买东西,一个人给您5,但另一个人不诚实,只给您发送1。这些可能发生在同一区块中,但不会出现在同一笔交易中,因为它们起源于不同的钱包。 If your puzzle is over how to tell them apart, ie which person sent you the 5 and which person sent you the 1, this is why you get your wallet to generate 2 different addresses and give one to each person. 如果您的难题在于如何区分他们,即哪个人给您发送了5,哪个人给了您发送了1,这就是为什么您让您的钱包生成2个不同的地址并给每个人一个的原因。 You could always tell that you were sent a 5 and a 1 because of separate transactions, but when you look at the different addresses the 5 and the 1 were sent to you can know which person sent the 1, because of the address they used. 您总是可以说由于交易分开而给您发送了5和1,但是当您查看不同的地址时,就将5和1发送给了您,因为他们使用的地址,您可以知道是哪个人发送了1。 Again, you're looking at the output side of the transaction, not the input side, because the dishonest person who sent the 1 can look on the block explorer and find out the input details the honest person used, and then claim to be the honest person. 同样,您正在查看事务的输出端,而不是输入端,因为发送1的最不诚实的人可以在区块浏览器中查看并找出诚实人使用的输入详细信息,然后声称是诚实的人。

If you look at a transaction block which have multiple inputs and outputs, you cannot learn the exact directions of inputs. 如果查看具有多个输入和输出的事务块,则无法了解输入的确切方向。 You are only able to know inputs, outputs, and their amounts. 您只能知道输入,输出及其数量。

For example, there are 3 inputs which are A, B, C, and 3 outputs which are D, E, F. They share same transaction block, so there is no way to say that A sent BTCs to D, E, or F. Possibility is 1/3, so this is what CoinJoin "Bitcoin transaction anonymizing technique" is based on. 例如,有3个输入分别为A,B,C和3个输出分别为D,E,F。它们共享同一事务块,因此无法说A将BTC发送给D,E或F可能性是1/3,所以这就是CoinJoin“比特币交易匿名化技术”的基础。

More on CoinJoin . 有关CoinJoin的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM