This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function LCOpenTimeout() public { | |
require(msg.sender == alice.id && status == LCStatus.Init); | |
if (now > timeout) { | |
EventLCNotOpened(); | |
selfdestruct(alice.id); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CheckSignature(address verifier, uint vid, address p1, uint cash1, uint subchan1, address Ingrid, | |
address p2, uint cash2, uint subchan2, uint validity, uint version, bytes sig) private view returns (bool) { | |
bytes32 msgHash = keccak256(vid, p1, cash1, subchan1, Ingrid, p2, cash2, subchan2, validity, version); | |
return libSignatures.verify(verifier, msgHash, sig); | |
} | |
function CheckVersion(address verifierA, address verifierB, uint vid, VirtualContract memory vc, uint version, bytes sigA, bytes sigB) private view returns (bool) { | |
if (!CheckSignature(verifierA, vid, vc.p1, vc.cash1, vc.subchan1, vc.Ingrid, vc.p2, vc.cash2, vc.subchan2, vc.validity, version, sigA)) | |
return false; | |
bytes32 msgHash = keccak256(vid, vc.p1, vc.cash1, vc.subchan1, vc.Ingrid, vc.p2, vc.cash2, vc.subchan2, vc.validity, version, sigA); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function VCAlreadyClosed(uint vid, bytes sig) AliceOrBob public { | |
require((msg.sender != virtual[vid].Ingrid && (virtual[vid].status == VCStatus.Closing || virtual[vid].status == VCStatus.ClosingFinal)) || | |
(msg.sender == virtual[vid].Ingrid && virtual[vid].status == VCStatus.Timeouted)); | |
bytes32 msgHash = keccak256(vid, alreadyClosed); | |
require(libSignatures.verify(Other(msg.sender, alice.id, bob.id), msgHash, sig)); | |
EventClosed(); | |
selfdestruct(msg.sender); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function VCCloseTimeoutTimeout(uint vid) AliceOrBob public { | |
VirtualContract memory vc = virtual[vid]; | |
require(vc.status == VCStatus.Timeouted && msg.sender != vc.Ingrid); | |
if (now > vc.timeout) { | |
EventClosed(); | |
selfdestruct(msg.sender); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function VCCloseTimeout(uint vid, address p1, uint cash1, uint subchan1, address Ingrid, | |
address p2, uint cash2, uint subchan2, uint validity, bytes sig) AliceOrBob public { | |
require(virtual[vid].status != VCStatus.Closed && virtual[vid].status != VCStatus.Timeouted && msg.sender != Ingrid); | |
CheckVC(vid, p1, cash1, subchan1, Ingrid, p2, cash2, subchan2, validity, sig); | |
if (now > validity + 2 * closingTime) { | |
virtual[vid].status = VCStatus.Timeouted; | |
virtual[vid].Ingrid = Ingrid; | |
virtual[vid].timeout = now + closingTime; | |
EventVCClosing(vid); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function VCCloseFinalTimeout(uint vid) AliceOrBob public { | |
VirtualContract memory vc = virtual[vid]; | |
require(vc.status == VCStatus.ClosingFinal && msg.sender == vc.Ingrid); | |
if (now > vc.timeout) { | |
alice.totalTransfers += int(vc.cashFinal1) - int(vc.cash1); | |
bob.totalTransfers += int(vc.cashFinal2) - int(vc.cash2); | |
virtual[vid].status = VCStatus.Closed; | |
EventClosed(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function VCCloseFinal(uint vid, uint cash1A, uint cash2A, uint versionA, bytes sigA, bytes sigAB, | |
uint cash1B, uint cash2B, uint versionB, bytes sigB, bytes sigBA) AliceOrBob public { | |
VirtualContract memory vc = virtual[vid]; | |
require(msg.sender == vc.Ingrid && (vc.status == VCStatus.WaitingToClose || vc.status == VCStatus.Closing)); | |
require(CheckVersion(vc.p1, vc.p2, vid, vc, versionA, sigA, sigAB)); | |
require(CheckVersion(vc.p2, vc.p1, vid, vc, versionB, sigB, sigBA)); | |
if (versionA >= versionB) { | |
vc.cashFinal1 = cash1A; | |
vc.cashFinal2 = cash2A; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function VCClose(uint vid, uint cash1, uint cash2, uint version, bytes sig, bytes sigB) AliceOrBob public { | |
VirtualContract memory vc = virtual[vid]; | |
require(vc.status == VCStatus.Closing); | |
require(msg.sender != vc.Ingrid); | |
vc.cashFinal1 = cash1; | |
vc.cashFinal2 = cash2; | |
require(CheckVersion(Other(msg.sender, vc.p1, vc.p2), msg.sender, vid, vc, version, sig, sigB)); | |
EventVCClose(vid, cash1, cash2, version, sig, sigB); // smart contract is getting the info for Ingrid | |
vc.status = VCStatus.WaitingToClose; | |
virtual[vid] = vc; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function VCCloseInitTimeout(uint vid) AliceOrBob public { | |
require(virtual[vid].status == VCStatus.Closing && msg.sender == virtual[vid].Ingrid); | |
if (now > virtual[vid].timeout) { | |
EventClosed(); | |
selfdestruct(msg.sender); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function VCCloseInit(uint vid, address p1, uint cash1, uint subchan1, address Ingrid, | |
address p2, uint cash2, uint subchan2, uint validity, bytes sig) AliceOrBob public { | |
require(now > validity && Ingrid == msg.sender && virtual[vid].status == VCStatus.Empty); | |
CheckVC(vid, p1, cash1, subchan1, Ingrid, p2, cash2, subchan2, validity, sig); // open certificate | |
virtual[vid] = VirtualContract(p1, cash1, subchan1, Ingrid, p2, cash2, subchan2, validity, VCStatus.Closing, 0, 0, now + closingTime); | |
EventVCClosingInit(vid); | |
} |
NewerOlder