Transfer lifecycle
This document describes a transfer from Alice's account to Bob's account.
Notarize transaction
Alice initiates a transfer by sending a signed notarizeTransaction
message to
the Notary. The message contains an accountLedger
document and it contains a
transfer
transaction
type.
The transaction contains two items:
transfer
- contains information about the accounts that the transfer will be performed between
balanceStatement
- contains a proposal about the balance and transaction/issued numbers if the transfer is successful
Everything is signed by Alice.
Alice initializes a transfer
Notary responds with @notarizeTransaction
message. It contains
accountLedger
with transaction type atTransfer
(response to transaction
transfer
). The transaction contains a response for each item. The items' status
is acknowledgement
or rejection
.
atBalanceStatement
- contains attribute
outboxNewTransNum
that contains number of new transaction that the Notary dropped to Alice's outbox and Bob's inbox. atTransfer
Both items contain an inReferenceTo
the whole copy of original item. The response
item is signed by the Notary to prove that the Notary agreed with it. Both items
have set inReferenceTo
, numberOfOrigin
and transactionNum
to origin
Alice's transaction number.
When the Notary accepts Alice's transaction, the Notary creates a new pending
transaction and puts it into Bob's inbox and Alice's outbox.
Alice expects a new transaction in her outbox, so she downloads it by
combination of getAccountData
, getBoxReceipt
.
TODO: why has Alice new copy of transfer.
Bob gets transfer to inbox
The same is done by Bob. Using getAccountData
and getBoxReceipt
messages,
Bob downloads a new receipt from his inbox. The receipt contains a pending
transaction signed by the Notary. The transaction contains Alice's original
transfer
with her signature.
Bob accepts the pending
transaction by performing a new processInbox
transaction. This transaction contains two items:
acceptPending
numberOfOrigin
points to Alice's originaltransfer
transactionNum
is a new transaction number, same asprocessInbox
inReferenceTo
points to the transaction that Bob is responding to (generated by Notary after Alice senttransfer
)balanceStatement
with new proposed balance and transaction numbers
Notary accepts Bob's processInbox
and sends atAcceptPending
to Bob in reply.
As Bob accepted the transfer, Notary generates a new transferReceipt
transaction and drops it into Alice's inbox.
Alice gets a notification that the transfer is complete
Alice receives a new transferReceipt
in her inbox.
numberOfOrigin
points to Alice's originaltransfer
transactionNum
is the new transaction numberinReferenceTo
points to Bob'sprocessInbox
inRefDisplay
points to Alice's originaltransfer
- element
inReferenceTo
contains a copy of Bob'sacceptPending
, with his signature, so Alice has proof that Bob accepted the transfer and it is also signed by the Notary. TODO: we do not see that the client checks it, in the current code
Alice responds to transferReceipt
by acceptItemReceipt
in processInbox
.
Notary sends atAcceptItemReceipt
.