Bitcoin Forum
April 23, 2024, 08:35:46 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: Creare transazione con "ritardo"  (Read 3165 times)
arulbero
Legendary
*
Offline Offline

Activity: 1914
Merit: 2071


View Profile
March 22, 2015, 04:59:17 PM
 #21

Quote
Sequence numbers are intended to be used for replacement. Replacement is currently disabled, but how it would work is:

 - You send a transaction with a LockTime in the future and a sequence number of 0. The transaction is then not considered by the network to be "final", and it can't be included in a block until the specified LockTime is reached.
 - Before LockTime expires, you can replace the transaction with as many new versions as you want. Newer versions have higher sequence numbers.
 - If you ever want to lock the transaction permanently, you can set the sequence number to UINT_MAX. Then the transaction is considered to be final, even if LockTime has not been reached.

This is useful in several cases. For example, two parties can use it to set up a "prepared transaction". Once the prepared transaction is created, the parties can move money between each other instantly, securely, and without fees. So you could set one of these up with an exchange and withdraw and deposit without waiting for confirmations.

Since replacement is not used currently, all transactions Bitcoin creates have LockTime = 0 and Sequence = UINT_MAX.

Mi sfugge il vantaggio di una transazione con LockTime > 0. Se comunque, una volta preparata la transazione, non é possibile trasmetterla alla rete con troppo anticipo perchè verrebbe presto "dimenticata", non sarebbe allora la stessa cosa preparare una transazione standard con LockTime = 0, firmarla, tenerla sul proprio pc e inviarla poi alla rete quando si ritiene più opportuno?

In che senso " le due parti potrebbero scambiarsi i bitcoin istantaneamente e senza fee, e senza aspettare le conferme? "  Huh

1713861346
Hero Member
*
Offline Offline

Posts: 1713861346

View Profile Personal Message (Offline)

Ignore
1713861346
Reply with quote  #2

1713861346
Report to moderator
1713861346
Hero Member
*
Offline Offline

Posts: 1713861346

View Profile Personal Message (Offline)

Ignore
1713861346
Reply with quote  #2

1713861346
Report to moderator
1713861346
Hero Member
*
Offline Offline

Posts: 1713861346

View Profile Personal Message (Offline)

Ignore
1713861346
Reply with quote  #2

1713861346
Report to moderator
You can see the statistics of your reports to moderators on the "Report to moderator" pages.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713861346
Hero Member
*
Offline Offline

Posts: 1713861346

View Profile Personal Message (Offline)

Ignore
1713861346
Reply with quote  #2

1713861346
Report to moderator
1713861346
Hero Member
*
Offline Offline

Posts: 1713861346

View Profile Personal Message (Offline)

Ignore
1713861346
Reply with quote  #2

1713861346
Report to moderator
1713861346
Hero Member
*
Offline Offline

Posts: 1713861346

View Profile Personal Message (Offline)

Ignore
1713861346
Reply with quote  #2

1713861346
Report to moderator
arulbero
Legendary
*
Offline Offline

Activity: 1914
Merit: 2071


View Profile
March 29, 2015, 09:12:40 PM
 #22

Provo a fare un esperimento. La transazione è questa:

0100000002e8bfdc8d6a7c318926dcf312be9f270a94765931d9562afc6c2d494b8386f0a325000 0008c4930460221008e481b288a958629715f9f4ce24ac95ca64a04885f757f44681bccd271ae0d 28022100dbe7494844f8fd2b85960a8bff7955c82b9f5a6dcabd83cecf5f13070d171d04014104e 4da05e963255705ed524278005893cb7b95cd32ce009d8f7c8e88f28bdc35a12985086f434cc01b 0bb4fdf7aae9de1b46bbe301abdabd5d2412ebae3fe7cf04ffffffffa0193a457ca7b5aca27ba3a 5b8f3f57eab95ac530b0368d824922123740357ae330000008b483045022035e6c418fb045a5610 6ff4044c9db28027b624d302e09f186c53af08c63bac6c022100d073c28d2c0292460832fd71288 5f6e3e9d5208b5d70ded20e08e182763b918a014104e4da05e963255705ed524278005893cb7b95 cd32ce009d8f7c8e88f28bdc35a12985086f434cc01b0bb4fdf7aae9de1b46bbe301abdabd5d241 2ebae3fe7cf04ffff0fff01d41d0000000000001976a91492e7bae1123b7c58c954f4dfc32035a53fa6d8e788ac023f0500

anzichè ffffffff (che corrisponde al "fondoscala", cioè a infinito) ho messo ffff0fff, cioè un numero a caso. Ovviamente ciò va fatto prima di firmare la transazione.

Ora mi dice "The transaction is not final", dovrebbe poter essere possibile inviare la transazione solo dopo il blocco 343810, vediamo se funziona...


Ho provato anch'io a effettuare una transazione simile con nlocktime modificato, mi esce sempre il messaggio "The transaction is not final" e poi non succede nulla.

Guardando in rete ho trovato:

The release notes for Bitcoin Core (Satoshi client) version 0.9.0 states
"Accept nLockTime transactions that finalize in the next block"


quindi comunque bisogna aspettare per inviare la transazione che questa diventi "finale", in pratica non é possibile inviarla in anticipo.

bit3000 (OP)
Sr. Member
****
Offline Offline

Activity: 448
Merit: 250


Craig Wright is scammer.


View Profile
March 30, 2015, 07:52:58 PM
 #23

Mi sfugge il vantaggio di una transazione con LockTime > 0. Se comunque, una volta preparata la transazione, non é possibile trasmetterla alla rete con troppo anticipo perchè verrebbe presto "dimenticata", non sarebbe allora la stessa cosa preparare una transazione standard con LockTime = 0, firmarla, tenerla sul proprio pc e inviarla poi alla rete quando si ritiene più opportuno?
beh, se però si elimina la chiave privata dell'indirizzo del mittente, si ottiene una quantità di bitcoin "bloccati" che è possibile spendere solo dopo una certa data. Ciò può essere utile a vari scopi.



Ho provato anch'io a effettuare una transazione simile con nlocktime modificato, mi esce sempre il messaggio "The transaction is not final" e poi non succede nulla.

Guardando in rete ho trovato:

The release notes for Bitcoin Core (Satoshi client) version 0.9.0 states
"Accept nLockTime transactions that finalize in the next block"


quindi comunque bisogna aspettare per inviare la transazione che questa diventi "finale", in pratica non é possibile inviarla in anticipo.


esatto, la transazione va "preparata" e poi inviata una volta raggiunto il locktime stabilito

Old Amazon Accounts.With 100-200$ Gift card loaded.
Escrowed.
arulbero
Legendary
*
Offline Offline

Activity: 1914
Merit: 2071


View Profile
March 31, 2015, 11:04:31 AM
Last edit: March 31, 2015, 12:05:50 PM by arulbero
 #24

Mi sfugge il vantaggio di una transazione con LockTime > 0. Se comunque, una volta preparata la transazione, non é possibile trasmetterla alla rete con troppo anticipo perchè verrebbe presto "dimenticata", non sarebbe allora la stessa cosa preparare una transazione standard con LockTime = 0, firmarla, tenerla sul proprio pc e inviarla poi alla rete quando si ritiene più opportuno?
beh, se però si elimina la chiave privata dell'indirizzo del mittente, si ottiene una quantità di bitcoin "bloccati" che è possibile spendere solo dopo una certa data. Ciò può essere utile a vari scopi.


É proprio questo il punto che ancora non mi è chiaro, cioè i diversi meccanismi che si possono utilizzare per firmare le transazioni o subordinare una transazione a un'altra, i meccanismi che stanno insomma alla base dei contratti.

Ho trovato questo esempio (che penso sia più o meno la spiegazione di come funziona GreenAddress)
Quote
Example 1: Providing a deposit
Imagine that you open an account on a website (eg, a forum or wiki) and wish to establish your trustworthiness with the operators, but you don't have any pre-existing reputation to leverage. One solution is to buy trust by paying the website some money. But if at some point you close your account, you'd probably like that money back. You may not trust the site enough to give them a deposit that they are tempted to spend. Another risk is that the site might just disappear one day.

The goal is to prove that you made a sacrifice of some kind so the site knows you're not a spambot, but you don't want them to be able to spend the money. And if the operators disappear, you'd eventually like the coins back without needing anything from them.

We can solve this problem with a contract:

The user and website send each other a newly-generated public key.
The user creates transaction Tx1 (the payment) putting 10 BTC into an output that requires both user and website to sign, but does not broadcast it. They use the key from the previous step for the site.
User sends the hash of Tx1 to the website.
The website creates a transaction Tx2 (the contract). Tx2 spends Tx1 and pays it back to the user via the address he provided in the first step. Note that Tx1 requires two signatures, so this transaction can't be complete. nLockTime is set to some date in the future (eg, six months). The sequence number on the input is set to zero.
Finally, the incomplete (half-signed) transaction is sent back to the user. The user checks that the contract is as expected - that the coins will eventually come back to him - but, unless things are changed, only after six months. Because the sequence number is zero, the contract can be amended in future if both parties agree. The script in the input isn't finished though; there are only zeros where the user's signature should be. He fixes that by signing the contract and putting the new signature in the appropriate spot.
The user broadcasts Tx1, then broadcasts Tx2.
At this stage, the 10 BTC are in a state where neither the user nor the website can spend them independently. After six months, the contract will complete and the user will get the coins back, even if the website disappears.

In questo caso il contratto ( che é la Tx2 che spende l'output della Tx1) è la transazione con nlocktime modificato e questa deve essere conservata dall'utente che può trasmetterla alla rete solo dopo sei mesi, se ho ben capito? L'output della Tx1 é bloccato per 6 mesi (a meno che le due parti non cambino entrambe idea prima e modifichino il contratto, cioé la Tx2).

L'idea del nlocktime e del sequence number dovrebbe essere all'incirca: stabiliamo da quale momento in poi questi fondi saranno sbloccati, se cambiamo idea facciamo un altro contratto con il sequence number modificato; é comunque l'utente che deve ricordarsi di trasmettere al momento opportuno la transazione con il sequence number più alto dal momento che la rete non é in grado di stabilire se dato un contratto ne esiste una versione più aggiornata (a meno che tutte le versioni esistenti non siano inviate alla rete nello stesso momento, in tal caso la rete stessa sceglie quella con il sequence number più alto e scarta le altre versioni).

Pages: « 1 [2]  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!