@ -182,12 +182,7 @@ class RawTransactionsTest(BitcoinTestFramework):
dec_tx = self . nodes [ 2 ] . decoderawtransaction ( rawtx )
dec_tx = self . nodes [ 2 ] . decoderawtransaction ( rawtx )
assert_equal ( utx [ ' txid ' ] , dec_tx [ ' vin ' ] [ 0 ] [ ' txid ' ] )
assert_equal ( utx [ ' txid ' ] , dec_tx [ ' vin ' ] [ 0 ] [ ' txid ' ] )
try :
assert_raises_jsonrpc ( - 3 , " Unexpected key foo " , self . nodes [ 2 ] . fundrawtransaction , rawtx , { ' foo ' : ' bar ' } )
self . nodes [ 2 ] . fundrawtransaction ( rawtx , { ' foo ' : ' bar ' } )
raise AssertionError ( " Accepted invalid option foo " )
except JSONRPCException as e :
assert ( " Unexpected key foo " in e . error [ ' message ' ] )
############################################################
############################################################
# test a fundrawtransaction with an invalid change address #
# test a fundrawtransaction with an invalid change address #
@ -200,12 +195,7 @@ class RawTransactionsTest(BitcoinTestFramework):
dec_tx = self . nodes [ 2 ] . decoderawtransaction ( rawtx )
dec_tx = self . nodes [ 2 ] . decoderawtransaction ( rawtx )
assert_equal ( utx [ ' txid ' ] , dec_tx [ ' vin ' ] [ 0 ] [ ' txid ' ] )
assert_equal ( utx [ ' txid ' ] , dec_tx [ ' vin ' ] [ 0 ] [ ' txid ' ] )
try :
assert_raises_jsonrpc ( - 5 , " changeAddress must be a valid bitcoin address " , self . nodes [ 2 ] . fundrawtransaction , rawtx , { ' changeAddress ' : ' foobar ' } )
self . nodes [ 2 ] . fundrawtransaction ( rawtx , { ' changeAddress ' : ' foobar ' } )
raise AssertionError ( " Accepted invalid bitcoin address " )
except JSONRPCException as e :
assert ( " changeAddress must be a valid bitcoin address " in e . error [ ' message ' ] )
############################################################
############################################################
# test a fundrawtransaction with a provided change address #
# test a fundrawtransaction with a provided change address #
@ -219,12 +209,7 @@ class RawTransactionsTest(BitcoinTestFramework):
assert_equal ( utx [ ' txid ' ] , dec_tx [ ' vin ' ] [ 0 ] [ ' txid ' ] )
assert_equal ( utx [ ' txid ' ] , dec_tx [ ' vin ' ] [ 0 ] [ ' txid ' ] )
change = self . nodes [ 2 ] . getnewaddress ( )
change = self . nodes [ 2 ] . getnewaddress ( )
try :
assert_raises_jsonrpc ( - 8 , " changePosition out of bounds " , self . nodes [ 2 ] . fundrawtransaction , rawtx , { ' changeAddress ' : change , ' changePosition ' : 2 } )
rawtxfund = self . nodes [ 2 ] . fundrawtransaction ( rawtx , { ' changeAddress ' : change , ' changePosition ' : 2 } )
except JSONRPCException as e :
assert ( ' changePosition out of bounds ' == e . error [ ' message ' ] )
else :
assert ( False )
rawtxfund = self . nodes [ 2 ] . fundrawtransaction ( rawtx , { ' changeAddress ' : change , ' changePosition ' : 0 } )
rawtxfund = self . nodes [ 2 ] . fundrawtransaction ( rawtx , { ' changeAddress ' : change , ' changePosition ' : 0 } )
dec_tx = self . nodes [ 2 ] . decoderawtransaction ( rawtxfund [ ' hex ' ] )
dec_tx = self . nodes [ 2 ] . decoderawtransaction ( rawtxfund [ ' hex ' ] )
out = dec_tx [ ' vout ' ] [ 0 ]
out = dec_tx [ ' vout ' ] [ 0 ]
@ -333,12 +318,7 @@ class RawTransactionsTest(BitcoinTestFramework):
rawtx = self . nodes [ 2 ] . createrawtransaction ( inputs , outputs )
rawtx = self . nodes [ 2 ] . createrawtransaction ( inputs , outputs )
dec_tx = self . nodes [ 2 ] . decoderawtransaction ( rawtx )
dec_tx = self . nodes [ 2 ] . decoderawtransaction ( rawtx )
try :
assert_raises_jsonrpc ( - 4 , " Insufficient funds " , self . nodes [ 2 ] . fundrawtransaction , rawtx )
rawtxfund = self . nodes [ 2 ] . fundrawtransaction ( rawtx )
raise AssertionError ( " Spent more than available " )
except JSONRPCException as e :
assert ( " Insufficient " in e . error [ ' message ' ] )
############################################################
############################################################
#compare fee of a standard pubkeyhash transaction
#compare fee of a standard pubkeyhash transaction
@ -494,21 +474,13 @@ class RawTransactionsTest(BitcoinTestFramework):
rawTx = self . nodes [ 1 ] . createrawtransaction ( inputs , outputs )
rawTx = self . nodes [ 1 ] . createrawtransaction ( inputs , outputs )
# fund a transaction that requires a new key for the change output
# fund a transaction that requires a new key for the change output
# creating the key must be impossible because the wallet is locked
# creating the key must be impossible because the wallet is locked
try :
assert_raises_jsonrpc ( - 4 , " Insufficient funds " , self . nodes [ 1 ] . fundrawtransaction , rawtx )
fundedTx = self . nodes [ 1 ] . fundrawtransaction ( rawTx )
raise AssertionError ( " Wallet unlocked without passphrase " )
except JSONRPCException as e :
assert ( ' Keypool ran out ' in e . error [ ' message ' ] )
#refill the keypool
#refill the keypool
self . nodes [ 1 ] . walletpassphrase ( " test " , 100 )
self . nodes [ 1 ] . walletpassphrase ( " test " , 100 )
self . nodes [ 1 ] . walletlock ( )
self . nodes [ 1 ] . walletlock ( )
try :
assert_raises_jsonrpc ( - 13 , " walletpassphrase " , self . nodes [ 1 ] . sendtoaddress , self . nodes [ 0 ] . getnewaddress ( ) , 1.2 )
self . nodes [ 1 ] . sendtoaddress ( self . nodes [ 0 ] . getnewaddress ( ) , 1.2 )
raise AssertionError ( " Wallet unlocked without passphrase " )
except JSONRPCException as e :
assert ( ' walletpassphrase ' in e . error [ ' message ' ] )
oldBalance = self . nodes [ 0 ] . getbalance ( )
oldBalance = self . nodes [ 0 ] . getbalance ( )