13 print(
"Initializing test directory "+self.options.tmpdir)
17 self.
nodes =
start_nodes(4, self.options.tmpdir, [[
'-usehd=0'], [
'-usehd=0'], [
'-usehd=0'], [
'-usehd=0']])
28 print "Mining blocks..." 33 for node
in self.
nodes:
34 node.settxfee(min_relay_tx_fee)
42 feeTolerance = 2 * min_relay_tx_fee/1000
51 watchonly_amount = Decimal(2000)
72 fee = rawtxfund[
'fee']
74 assert(len(dec_tx[
'vin']) > 0)
85 fee = rawtxfund[
'fee']
87 assert(len(dec_tx[
'vin']) > 0)
98 fee = rawtxfund[
'fee']
100 assert(len(dec_tx[
'vin']) > 0)
113 fee = rawtxfund[
'fee']
116 for out
in dec_tx[
'vout']:
117 totalOut += out[
'value']
119 assert(len(dec_tx[
'vin']) > 0)
128 for aUtx
in listunspent:
129 if aUtx[
'amount'] == 50:
135 inputs = [ {
'txid' : utx[
'txid'],
'vout' : utx[
'vout']}]
142 fee = rawtxfund[
'fee']
145 for out
in dec_tx[
'vout']:
146 totalOut += out[
'value']
156 for aUtx
in listunspent:
157 if aUtx[
'amount'] == 50:
163 inputs = [ {
'txid' : utx[
'txid'],
'vout' : utx[
'vout']}]
170 fee = rawtxfund[
'fee']
173 for out
in dec_tx[
'vout']:
174 totalOut += out[
'value']
185 for aUtx
in listunspent:
186 if aUtx[
'amount'] == 10:
192 inputs = [ {
'txid' : utx[
'txid'],
'vout' : utx[
'vout']}]
197 rawtx = rawtx[:82] +
"0100" + rawtx[84:]
201 assert_equal(
"00", dec_tx[
'vin'][0][
'scriptSig'][
'hex'])
204 fee = rawtxfund[
'fee']
208 for i, out
in enumerate(dec_tx[
'vout']):
209 totalOut += out[
'value']
210 if out[
'scriptPubKey'][
'addresses'][0]
in outputs:
216 assert_equal(
"00", dec_tx[
'vin'][0][
'scriptSig'][
'hex'])
228 for aUtx
in listunspent:
229 if aUtx[
'amount'] == 10:
231 if aUtx[
'amount'] == 50:
237 inputs = [ {
'txid' : utx[
'txid'],
'vout' : utx[
'vout']},{
'txid' : utx2[
'txid'],
'vout' : utx2[
'vout']} ]
244 fee = rawtxfund[
'fee']
248 for out
in dec_tx[
'vout']:
249 totalOut += out[
'value']
250 if out[
'scriptPubKey'][
'addresses'][0]
in outputs:
257 for vinOut
in dec_tx[
'vin']:
259 if vinIn[
'txid'] == vinOut[
'txid']:
270 for aUtx
in listunspent:
271 if aUtx[
'amount'] == 10:
273 if aUtx[
'amount'] == 50:
279 inputs = [ {
'txid' : utx[
'txid'],
'vout' : utx[
'vout']},{
'txid' : utx2[
'txid'],
'vout' : utx2[
'vout']} ]
286 fee = rawtxfund[
'fee']
290 for out
in dec_tx[
'vout']:
291 totalOut += out[
'value']
292 if out[
'scriptPubKey'][
'addresses'][0]
in outputs:
302 inputs = [ {
'txid' :
"1c7f966dab21119bac53213a2bc7532bff1fa844c124fd750a7d0b1332440bd1",
'vout' : 0} ]
309 raise AssertionError(
"Spent more than available")
310 except JSONRPCException
as e:
311 assert(
"Insufficient" in e.error[
'message'])
326 feeDelta = Decimal(fundedTx[
'fee']) - Decimal(signedFee)
327 assert(feeDelta >= 0
and feeDelta <= feeTolerance)
341 feeDelta = Decimal(fundedTx[
'fee']) - Decimal(signedFee)
342 assert(feeDelta >= 0
and feeDelta <= feeTolerance)
359 outputs = {mSigObj:11}
368 feeDelta = Decimal(fundedTx[
'fee']) - Decimal(signedFee)
369 assert(feeDelta >= 0
and feeDelta <= feeTolerance)
389 mSigObj = self.
nodes[1].
addmultisigaddress(4, [addr1Obj[
'pubkey'], addr2Obj[
'pubkey'], addr3Obj[
'pubkey'], addr4Obj[
'pubkey'], addr5Obj[
'pubkey']])
392 outputs = {mSigObj:11}
401 feeDelta = Decimal(fundedTx[
'fee']) - Decimal(signedFee)
402 assert(feeDelta >= 0
and feeDelta <= feeTolerance)
447 self.
nodes =
start_nodes(4, self.options.tmpdir, [[
'-usehd=0'], [
'-usehd=0'], [
'-usehd=0'], [
'-usehd=0']])
450 for node
in self.
nodes:
451 node.settxfee(min_relay_tx_fee)
469 raise AssertionError(
"Wallet unlocked without passphrase")
470 except JSONRPCException
as e:
471 assert(
'Keypool ran out' in e.error[
'message'])
479 raise AssertionError(
"Wallet unlocked without passphrase")
480 except JSONRPCException
as e:
481 assert(
'walletpassphrase' in e.error[
'message'])
512 for i
in range(0,20):
529 feeDelta = Decimal(fundedTx[
'fee']) - Decimal(signedFee)
530 assert(feeDelta >= 0
and feeDelta <= feeTolerance*19)
543 for i
in range(0,20):
567 rawtx =
"0100000000010000000000000000066a047465737400000000" 593 assert(
"fee" in result.keys())
607 assert(res_dec[
"vin"][0][
"txid"] == watchonly_txid
or res_dec[
"vin"][1][
"txid"] == watchonly_txid)
611 assert_equal(result[
"fee"] + res_dec[
"vout"][result[
"changepos"]][
"value"], watchonly_amount / 10)
614 assert(
not signedtx[
"complete"])
616 assert(signedtx[
"complete"])
620 if __name__ ==
'__main__':
UniValue addmultisigaddress(const UniValue ¶ms, bool fHelp)
UniValue walletpassphrase(const UniValue ¶ms, bool fHelp)
UniValue importpubkey(const UniValue ¶ms, bool fHelp)
UniValue validateaddress(const UniValue ¶ms, bool fHelp)
def assert_greater_than(thing1, thing2)
UniValue getbalance(const UniValue ¶ms, bool fHelp)
def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None)
UniValue sendmany(const UniValue ¶ms, bool fHelp)
def setup_network(self, split=False)
UniValue listunspent(const UniValue ¶ms, bool fHelp)
UniValue sendtoaddress(const UniValue ¶ms, bool fHelp)
UniValue getnewaddress(const UniValue ¶ms, bool fHelp)
def initialize_chain_clean(test_dir, num_nodes)
UniValue signrawtransaction(const UniValue ¶ms, bool fHelp)
UniValue createrawtransaction(const UniValue ¶ms, bool fHelp)
UniValue decoderawtransaction(const UniValue ¶ms, bool fHelp)
UniValue encryptwallet(const UniValue ¶ms, bool fHelp)
UniValue generate(const UniValue ¶ms, bool fHelp)
UniValue sendrawtransaction(const UniValue ¶ms, bool fHelp)
UniValue getrawmempool(const UniValue ¶ms, bool fHelp)
UniValue getnetworkinfo(const UniValue ¶ms, bool fHelp)
def assert_equal(thing1, thing2)
def connect_nodes_bi(nodes, a, b)
UniValue walletlock(const UniValue ¶ms, bool fHelp)