简体   繁体   English

获取离线比特币交易ID,链接多个离线交易

[英]get offline Bitcoin transaction id, chain multiple offline transactions

let's say i create a valid transaction (offline without sending it, such as like this: http://brainwallet.org/#tx . let's call this " A " 假设我创建了一个有效的交易(离线但不发送交易,例如: http : //brainwallet.org/#tx 。我们称其为“ A

a)before having sent A, can i get the transaction ID of A? a)在发送A之前,我能否获得A的交易ID?

b)I wish to create a new offline Transaction (called B ), using the outputs from A as inputs for B.Still, A has not been sent to the bitcoin network. b)我希望使用A的输出作为B的输入来创建一个新的脱机交易(称为B )。但是,A尚未发送到比特币网络。 Is this possible? 这可能吗?

c) if part b) is possible, and I send A, then immediately send B to the bitcoin network. c)如果b)部分可行,我发送A,然后立即将B发送到比特币网络。 what would happen? 会发生什么?

There is no transaction ID in the Bitcoin protocol but a transaction Hash. 比特币协议中没有交易ID,但有交易哈希。 To make it more clear you need to understand that a transaction has an input and an output. 为了更加清楚,您需要了解一个事务具有输入和输出。

  • The input is composed of the hash of the previous transaction and the signature script that will prove you are the owner of the coins. 输入由上一交易的哈希值和签名脚本组成,这些签名脚本将证明您是硬币的所有者。 As you can note there is no input amount because the entire provision of the address will be spend. 如您所见,由于地址的全部准备都将用完,因此没有输入金额。 The change will be send back to you in the transaction output. 更改将在交易输出中发送回给您。

  • The output is composed of an amount and a signature script. 输出由金额和签名脚本组成。 In this case the signature script give the condition that need to be filled to unlock the coins. 在这种情况下,签名脚本给出了需要满足的条件才能解锁硬币。

So yes you can create B without A has been sent to the network. 是的,您可以创建B,而无需将A发送到网络。

What will happen if you send A and B at the same time? 如果您同时发送AB ,将会怎样? Transaction A will be done for sure. 交易A一定会完成。 The after at least 3 new blocks B will probably be done too but this is not 100% sure because Miners will probably drop B from their memory until A is not spend. 至少也要完成至少3个新区块B,但这并不是100%肯定的,因为矿工可能会从内存中删除B,直到A没花完为止。

You can get more details about transactions here: https://en.bitcoin.it/wiki/Transactions 您可以在此处获取有关交易的更多详细信息: https : //en.bitcoin.it/wiki/Transactions

and about transaction scripts here: https://en.bitcoin.it/wiki/Script 有关交易脚本的信息,请访问: https//en.bitcoin.it/wiki/Script

What you have to remember before doing such things as creating new transactions depending on another unconfirmed (or even offline) transactions is that your transaction A hash (id) could change during mining process. 在根据其他未经确认(甚至是离线)的交易创建新交易之前,您要记住的是,交易(哈希)在挖掘过程中可能会发生变化。

So, you could send all of your A and B transactions to the network at any time, but there are several options: 因此,您可以随时将所有A和B交易发送到网络,但是有几种选择:

  1. Transaction A will be included in the next block and confirmed, so when transaction B will included in the next block and everything will be ok. 事务A将包含在下一个区块中并得到确认,因此,当事务B将包含在下一个区块中时,一切都会好的。
  2. Your transaction A will change it's hash during mining process (see Transaction Malleability) and be included in the next block with different hash (id). 您的事务A将在挖掘过程中更改其哈希值(请参阅事务可扩展性),并包含在具有不同哈希值(id)的下一个块中。 In that case your transaction B (which depends on offline calculated hash of transaction A, which is not valid anymore) will never be accepted by the network. 在那种情况下,您的交易B(取决于交易A的离线计算的哈希值,现在不再有效)将不会被网络接受。

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

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