change to shorter names
This commit is contained in:
parent
403ecc43e8
commit
0db4fec559
|
@ -1,11 +1,11 @@
|
|||
import zXcatForEth
|
||||
import zXcat
|
||||
import bXcat
|
||||
from xcat import *
|
||||
|
||||
print("Starting test of xcat...")
|
||||
|
||||
def Zcash_getaddr():
|
||||
return zXcatForEth.zcashd.getnewaddress()
|
||||
return zXcat.zcashd.getnewaddress()
|
||||
|
||||
|
||||
def Zcash_fund(p2sh,amount):
|
||||
|
@ -17,7 +17,7 @@ def Zcash_make_contract(funder, redeemer, hash_of_secret, lock_increment):
|
|||
|
||||
# finds seller's redeem tx and gets secret from it
|
||||
def Zcash_get_secret(p2sh,fund_txid):
|
||||
return zXcatForEth.find_secret(p2sh,fund_tx)
|
||||
return zXcat.find_secret(p2sh,fund_tx)
|
||||
|
||||
def Zcash_refund(contract):
|
||||
return zXcat.redeem_after_timelock(contract)
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
import zXcat
|
||||
import bXcat
|
||||
from xcat import *
|
||||
|
||||
print("Starting test of xcat...")
|
||||
|
||||
def Zcash_getaddr():
|
||||
return zXcat.zcashd.getnewaddress()
|
||||
|
||||
|
||||
def Zcash_fund(p2sh,amount):
|
||||
fund_txid = zXcat.zcashd.sendtoaddress(p2sh,amount)
|
||||
return fund_txid
|
||||
|
||||
def Zcash_make_contract(funder, redeemer, hash_of_secret, lock_increment):
|
||||
return zXcat.make_hashtimelockcontract(funder, redeemer, hash_of_secret, lock_increment)
|
||||
|
||||
# finds seller's redeem tx and gets secret from it
|
||||
def Zcash_get_secret(p2sh,fund_txid):
|
||||
return zXcat.find_secret(p2sh,fund_tx)
|
||||
|
||||
def Zcash_refund(contract):
|
||||
return zXcat.redeem_after_timelock(contract)
|
||||
|
||||
# returns txid of redeem transaction with secret
|
||||
def Zcash_redeem(contract,secret):
|
||||
txid = zXcat.redeem_with_secret(contract,secret)
|
||||
return txid
|
||||
|
||||
def redeem_buyer():
|
||||
print("BUYER REDEEMING SELL CONTRACT")
|
||||
print("=============================")
|
||||
trade = get_trade()
|
||||
buyContract = trade.buyContract
|
||||
sellContract = trade.sellContract
|
||||
secret = ""
|
||||
# if sellContract.get_status() == 'redeemed':
|
||||
# raise RuntimeError("Sell contract was redeemed before buyer could retrieve funds")
|
||||
# elif buyContract.get_status() == 'refunded':
|
||||
# print("buyContract was refunded to buyer")
|
||||
# else:
|
||||
# Buy contract is where seller disclosed secret in redeeming
|
||||
if buyContract.currency == 'bitcoin':
|
||||
if (bXcat.still_locked(buyContract)):
|
||||
if(not hasattr(buyContract,'fund_tx')):
|
||||
print("Seems address has not been funded yet. Aborting.")
|
||||
quit()
|
||||
secret = bXcat.find_secret(buyContract.p2sh,buyContract.fund_tx)
|
||||
if(secret != ""):
|
||||
print("Found secret in seller's redeem tx on bitcoin chain:", secret)
|
||||
else:
|
||||
if zXcat.still_locked(buyContract):
|
||||
secret = zXcat.find_secret(buyContract.p2sh,buyContract.fund_tx)
|
||||
if(secret != ""):
|
||||
print("Found secret in seller's redeem tx on zcash chain:", secret)
|
||||
redeem_tx = redeem_p2sh(sellContract, secret, buyContract)
|
||||
setattr(trade.sellContract, 'redeem_tx', redeem_tx)
|
||||
save(trade)
|
||||
|
||||
|
||||
def generate_blocks(num):
|
||||
bXcat.generate(num)
|
||||
zXcat.generate(num)
|
||||
|
Loading…
Reference in New Issue