add nonce support to WebRTC and Wallet

Each person keeps track of their own nonce, and the nonces of the other
copayers. The nonce is iterated for each message. If a person ever doesn't
iterate their nonce, that message is discarded by the copayers.

The nonces are saved as networkNonce (your nonce) and networkNonces (the nonces
of your copayers) in the wallet file.

In order to support restoring old wallets, the first four bytes of the 8 byte
nonce are actually the current time in seconds. Thus you can restore an old
wallet, because certainly at least one second has passed since your last
message. Only if you try to restore an old wallet within 1 second from the time
of your last message will you have a problem (or if your system clock is
grossly inaccurate).
This commit is contained in:
Ryan X. Charles 2014-07-08 23:03:30 -07:00
commit 88ab38eb00
6 changed files with 370 additions and 23 deletions

View file

@ -687,6 +687,7 @@ describe('Wallet model', function() {
done();
});
});
it('should send all TxProposal', function(done) {
var w = cachedCreateW2();
var utxo = createUTXO(w);
@ -700,6 +701,16 @@ describe('Wallet model', function() {
});
});
describe('#send', function() {
it('should call this.network.send', function () {
var w = cachedCreateW2();
var save = w.network.send;
w.network.send = sinon.spy();
w.send();
w.network.send.calledOnce.should.equal(true);
w.network.send = save;
});
});
describe('#indexDiscovery', function() {
var ADDRESSES_CHANGE, ADDRESSES_RECEIVE, w;