Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
(p2ptrade as implemented in NGCCC.)
First of all, we assume there is some sort of communication channel messages can be posted to. All participating agents receive all messages.
There are two kinds of objects: ExchangeOffer and ExchangeProposal.
ExchangeOffer, basically, says: I'm willing to exchange X coins of color A for Y coins of color B.
ExchangeProposal is a proposal to make a transaction.
Alice posts her exchange offer.
Bob finds Alice's exchange offer and creates ExchangeProposal. Exchange proposal includes:
- ExchangeOffer (possibly with some modifications, although partial fills are not yet implemented in NGCCC)
- Bob's txins (must have enough coins which Bob must send)
- Bob's txouts aka targets (what Bob wants to receive: change and payment)
Alice finds Bob's ExchangeProposal, she checks that it isn't screwed up, particularly that included offer is valid.
- If it is OK, Alice creates her own ExchangeProposal, it has same offer information (just for tracking reasons)
- Alice composes a transaction which uses both Alice's and Bob's inputs and txouts which pay both to Alice and Bob. Alice's txins are signed, but Bob's aren't, so this is an incomplete transaction.
Bob sees this updated ExchangeProposal, he checks whether Alice's payment is OK and all his txouts are included, then he signs his inputs.
- Now we have a complete transaction with all inputs signed. It can be submitted on the network.
- Bob does that, he also sends ExchangeProposal with a complete transaction.
Alice sees this complete transaction and now she knows that transfer is complete.