Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to new pyethereum api #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This github repo provides a simple implementation of basic bidirectional payment

Requirements
----
- bitcoin
- pyethereum
- solc

Expand All @@ -36,4 +37,3 @@ Contents

- contractSprite.sol, test_sprite.sol:
A duplex channel with conditional (hashed timelock) payments, but that supports constant expiry times

2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bitcoin >= 1.1.42
ethereum >= 2.3.1
20 changes: 11 additions & 9 deletions test_pay.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ethereum import tester
from ethereum.tools import tester
from ethereum import utils
from ethereum._solidity import get_solidity
from ethereum.tools._solidity import get_solidity
SOLIDITY_AVAILABLE = get_solidity() is not None
from Crypto.Hash import SHA256

Expand Down Expand Up @@ -47,7 +47,7 @@ def getstatus():
print 'Status:', ['OK','PENDING'][contract.status()]
print '[L] deposits:', depositsL, 'credits:', creditsL, 'withdrawals:', wdrawL
print '[R] deposits:', depositsR, 'credits:', creditsR, 'withdrawals:', wdrawR


class Player():
def __init__(self, sk, i, contract):
Expand All @@ -56,7 +56,7 @@ def __init__(self, sk, i, contract):
self.contract = contract
self.status = "OK"
self.lastRound = -1
self.lastCommit = None, (0, 0, 0, 0)
self.lastCommit = None, (0, 0, 0, 0)
self.lastProposed = None

def deposit(self, amt):
Expand Down Expand Up @@ -101,7 +101,7 @@ def receiveSignatures(self, r, sigs):

for i,sig in enumerate(sigs):
verify_signature(addrs[i], self.h, sig)

self.lastCommit = sigs, self.lastProposed
self.lastRound += 1

Expand All @@ -121,10 +121,10 @@ def update(self):
sigs, (creditsL, creditsR, withdrawalsL, withdrawalsR) = self.lastCommit
sig = sigs[1] if self.i == 0 else sigs[0]
self.contract.update(sig, self.lastRound, (creditsL, creditsR), (withdrawalsL, withdrawalsR), sender=self.sk)


# Create the simulated blockchain
s = tester.state()
s = tester.Chain()
s.mine()
tester.gas_limit = 3141592

Expand All @@ -135,8 +135,10 @@ def update(self):

# Create the contract
contract_code = open('contractPay.sol').read()
contract = s.abi_contract(contract_code, language='solidity',
constructor_parameters= ((addrs[0], addrs[1]),) )
contract = s.contract(
sourcecode=contract_code,
language='solidity',
args= ((addrs[0], addrs[1]),) )


def completeRound(players, r, payL, payR, wdrawL, wdrawR):
Expand Down