diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 99f3892..a539509 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -1715,7 +1715,7 @@ class BasicSwap(BaseApp): def postXmrBid(self, offer_id, amount, addr_send_from=None): # Bid to send bid.amount * offer.rate of coin_to in exchange for bid.amount of coin_from # Send MSG1L F -> L - self.log.debug('postBid %s %s', offer_id.hex(), format8(amount)) + self.log.debug('postXmrBid %s %s', offer_id.hex(), format8(amount)) self.mxDB.acquire() try: diff --git a/basicswap/interface_btc.py b/basicswap/interface_btc.py index 5f655db..4cf4283 100644 --- a/basicswap/interface_btc.py +++ b/basicswap/interface_btc.py @@ -216,6 +216,9 @@ class BTCInterface(CoinInterface): def sumPubkeys(self, Ka, Kb): return Ka + Kb + def getScriptForPubkeyHash(self, pkh): + return CScript([OP_0, pkh]) + def extractScriptLockScriptValues(self, script_bytes): script_len = len(script_bytes) assert_cond(script_len > 112, 'Bad script length') @@ -286,7 +289,7 @@ class BTCInterface(CoinInterface): script = self.genScriptLockTxScript(sh, Kal, Kaf, lock_blocks, Karl, Karf) tx = CTransaction() tx.nVersion = self.txVersion() - tx.vout.append(self.txoType(value, CScript([OP_0, hashlib.sha256(script).digest()]))) + tx.vout.append(self.txoType(value, self.getScriptDest(script))) return tx.serialize(), script @@ -388,7 +391,7 @@ class BTCInterface(CoinInterface): tx.nVersion = self.txVersion() tx.vin.append(CTxIn(COutPoint(tx_lock_refund_hash_int, locked_n), nSequence=0)) - tx.vout.append(self.txoType(locked_coin, CScript([OP_0, pkh_refund_to]))) + tx.vout.append(self.txoType(locked_coin, self.getScriptForPubkeyHash(pkh_refund_to))) witness_bytes = len(script_lock_refund) witness_bytes += 73 * 2 # 2 signatures (72 + 1 byte size) @@ -423,7 +426,7 @@ class BTCInterface(CoinInterface): tx.nVersion = self.txVersion() tx.vin.append(CTxIn(COutPoint(tx_lock_refund_hash_int, locked_n), nSequence=lock2_value)) - tx.vout.append(self.txoType(locked_coin, CScript([OP_0, pkh_dest]))) + tx.vout.append(self.txoType(locked_coin, self.getScriptForPubkeyHash(pkh_dest))) witness_bytes = len(script_lock_refund) witness_bytes += 73 # signature (72 + 1 byte size) @@ -453,8 +456,7 @@ class BTCInterface(CoinInterface): tx.nVersion = self.txVersion() tx.vin.append(CTxIn(COutPoint(tx_lock_hash_int, locked_n))) - p2wpkh = CScript([OP_0, pkh_dest]) - tx.vout.append(self.txoType(locked_coin, p2wpkh)) + tx.vout.append(self.txoType(locked_coin, self.getScriptForPubkeyHash(pkh_dest))) witness_bytes = len(script_lock) witness_bytes += 33 # sv, size @@ -668,7 +670,7 @@ class BTCInterface(CoinInterface): assert_cond(tx.vin[0].prevout.hash == b2i(lock_tx_id) and tx.vin[0].prevout.n == locked_n, 'Input prevout mismatch') assert_cond(len(tx.vout) == 1, 'tx doesn\'t have one output') - p2wpkh = CScript([OP_0, a_pkhash_f]) + p2wpkh = self.getScriptForPubkeyHash(a_pkhash_f) assert_cond(tx.vout[0].scriptPubKey == p2wpkh, 'Bad output destination') fee_paid = locked_coin - tx.vout[0].nValue @@ -771,7 +773,7 @@ class BTCInterface(CoinInterface): return CScript([OP_0, hashlib.sha256(script).digest()]) def getPkDest(self, K): - return CScript([OP_0, self.getPubkeyHash(K)]) + return self.getScriptForPubkeyHash(self.getPubkeyHash(K)) def scanTxOutset(self, dest): return self.rpc_callback('scantxoutset', ['start', ['raw({})'.format(dest.hex())]]) diff --git a/basicswap/interface_part.py b/basicswap/interface_part.py index b3e7f78..49c236d 100644 --- a/basicswap/interface_part.py +++ b/basicswap/interface_part.py @@ -8,6 +8,10 @@ from .contrib.test_framework.messages import ( CTxOutPart, ) +from .contrib.test_framework.script import ( + CScript, + OP_DUP, OP_HASH160, OP_EQUALVERIFY, OP_CHECKSIG +) from .interface_btc import BTCInterface from .chainparams import Coins @@ -52,3 +56,6 @@ class PARTInterface(BTCInterface): def withdrawCoin(self, value, addr_to, subfee): params = [addr_to, value, '', '', subfee, '', True, self._conf_target] return self.rpc_callback('sendtoaddress', params) + + def getScriptForPubkeyHash(self, pkh): + return CScript([OP_DUP, OP_HASH160, pkh, OP_EQUALVERIFY, OP_CHECKSIG]) diff --git a/doc/install.md b/doc/install.md index ce0b050..0986c2a 100644 --- a/doc/install.md +++ b/doc/install.md @@ -20,6 +20,8 @@ Create the images: Prepare the datadir: Set XMR_RPC_HOST and BASE_XMR_RPC_PORT to a public XMR node or exclude to run a local node. +Set xmrrestoreheight to the current xmr chain height. +Adjust `--withcoins` and `--withoutcoins` as desired, eg: `--withcoins=monero,bitcoin`. By default Particl and Litecoin are loaded. $ export COINDATA_PATH=/var/data/coinswaps $ docker run -e XMR_RPC_HOST="node.xmr.to" -e BASE_XMR_RPC_PORT=18081 -t --name swap_prepare -v $COINDATA_PATH:/coindata i_swapclient \ @@ -46,6 +48,7 @@ Open in browser: `http://localhost:12700` $ docker run -t --name swap_prepare -v $COINDATA_PATH:/coindata i_swapclient basicswap-prepare --datadir=/coindata --addcoin=bitcoin You can copy an existing pruned datadir (excluding bitcoin.conf and any wallets) over to `$COINDATA_PATH/bitcoin` +Remove any existing wallets after copying over a pruned chain or the Bitcoin daemon won't start. ## Run Without Docker: