Skip to content

Commit

Permalink
[log/test] udpate max-fee-exceeded error message
Browse files Browse the repository at this point in the history
  • Loading branch information
glozow committed Aug 15, 2020
1 parent a872d8d commit c763343
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/util/error.cpp
Expand Up @@ -30,7 +30,7 @@ bilingual_str TransactionErrorString(const TransactionError err)
case TransactionError::SIGHASH_MISMATCH:
return Untranslated("Specified sighash value does not match value stored in PSBT");
case TransactionError::MAX_FEE_EXCEEDED:
return Untranslated("Fee exceeds maximum configured by -maxtxfee");
return Untranslated("Fee exceeds maximum configured by user (eg -maxtxfee, maxfeerate)");
// no default case, so the compiler can warn about missing cases
}
assert(false);
Expand Down
2 changes: 1 addition & 1 deletion test/functional/rpc_fundrawtransaction.py
Expand Up @@ -667,7 +667,7 @@ def test_option_feerate(self):
result = self.nodes[3].fundrawtransaction(rawtx) # uses self.min_relay_tx_fee (set by settxfee)
result2 = self.nodes[3].fundrawtransaction(rawtx, {"feeRate": 2 * self.min_relay_tx_fee})
result3 = self.nodes[3].fundrawtransaction(rawtx, {"feeRate": 10 * self.min_relay_tx_fee})
assert_raises_rpc_error(-4, "Fee exceeds maximum configured by -maxtxfee", self.nodes[3].fundrawtransaction, rawtx, {"feeRate": 1})
assert_raises_rpc_error(-4, 'Fee exceeds maximum configured by user (eg -maxtxfee, maxfeerate)', self.nodes[3].fundrawtransaction, rawtx, {"feeRate": 1})
result_fee_rate = result['fee'] * 1000 / count_bytes(result['hex'])
assert_fee_amount(result2['fee'], count_bytes(result2['hex']), 2 * result_fee_rate)
assert_fee_amount(result3['fee'], count_bytes(result3['hex']), 10 * result_fee_rate)
Expand Down
5 changes: 3 additions & 2 deletions test/functional/rpc_psbt.py
Expand Up @@ -21,6 +21,7 @@
import os

MAX_BIP125_RBF_SEQUENCE = 0xfffffffd
MAX_FEE_EXCEEDED_MSG = 'Fee exceeds maximum configured by user (eg -maxtxfee, maxfeerate)'

# Create one-input, one-output, no-fee transaction:
class PSBTTest(BitcoinTestFramework):
Expand Down Expand Up @@ -172,8 +173,8 @@ def run_test(self):

# feeRate of 10 BTC / KB produces a total fee well above -maxtxfee
# previously this was silently capped at -maxtxfee
assert_raises_rpc_error(-4, "Fee exceeds maximum configured by -maxtxfee", self.nodes[1].walletcreatefundedpsbt, [{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():29.99}, 0, {"feeRate": 10, "add_inputs": True})
assert_raises_rpc_error(-4, "Fee exceeds maximum configured by -maxtxfee", self.nodes[1].walletcreatefundedpsbt, [{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():1}, 0, {"feeRate": 10, "add_inputs": False})
assert_raises_rpc_error(-4, MAX_FEE_EXCEEDED_MSG, self.nodes[1].walletcreatefundedpsbt, [{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():29.99}, 0, {"feeRate": 10, "add_inputs": True})
assert_raises_rpc_error(-4, MAX_FEE_EXCEEDED_MSG, self.nodes[1].walletcreatefundedpsbt, [{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():1}, 0, {"feeRate": 10, "add_inputs": False})

# partially sign multisig things with node 1
psbtx = wmulti.walletcreatefundedpsbt(inputs=[{"txid":txid,"vout":p2wsh_pos},{"txid":txid,"vout":p2sh_pos},{"txid":txid,"vout":p2sh_p2wsh_pos}], outputs={self.nodes[1].getnewaddress():29.99}, options={'changeAddress': self.nodes[1].getrawchangeaddress()})['psbt']
Expand Down
2 changes: 1 addition & 1 deletion test/functional/rpc_rawtransaction.py
Expand Up @@ -24,7 +24,7 @@
hex_str_to_bytes,
)

MAX_FEE_EXCEEDED_MSG = "Fee exceeds maximum configured by -maxtxfee"
MAX_FEE_EXCEEDED_MSG = "Fee exceeds maximum configured by user (eg -maxtxfee, maxfeerate)"

class multidict(dict):
"""Dictionary that allows duplicate keys.
Expand Down
2 changes: 1 addition & 1 deletion test/functional/wallet_bumpfee.py
Expand Up @@ -330,7 +330,7 @@ def test_maxtxfee_fails(self, rbf_node, dest_address):
self.restart_node(1, ['-maxtxfee=0.000025'] + self.extra_args[1])
rbf_node.walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT)
rbfid = spend_one_input(rbf_node, dest_address)
assert_raises_rpc_error(-4, "Unable to create transaction. Fee exceeds maximum configured by -maxtxfee", rbf_node.bumpfee, rbfid)
assert_raises_rpc_error(-4, "Unable to create transaction. Fee exceeds maximum configured by user (eg -maxtxfee, maxfeerate)", rbf_node.bumpfee, rbfid)
self.restart_node(1, self.extra_args[1])
rbf_node.walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT)

Expand Down
10 changes: 6 additions & 4 deletions test/functional/wallet_create_tx.py
Expand Up @@ -12,6 +12,8 @@
TIME_GENESIS_BLOCK,
)

MAX_FEE_EXCEEDED_MSG = 'Fee exceeds maximum configured by user (eg -maxtxfee, maxfeerate)'


class CreateTxWalletTest(BitcoinTestFramework):
def set_test_params(self):
Expand Down Expand Up @@ -53,12 +55,12 @@ def test_tx_size_too_large(self):
self.restart_node(0, extra_args=[fee_setting])
assert_raises_rpc_error(
-6,
"Fee exceeds maximum configured by -maxtxfee",
MAX_FEE_EXCEEDED_MSG,
lambda: self.nodes[0].sendmany(dummy="", amounts=outputs),
)
assert_raises_rpc_error(
-4,
"Fee exceeds maximum configured by -maxtxfee",
MAX_FEE_EXCEEDED_MSG,
lambda: self.nodes[0].fundrawtransaction(hexstring=raw_tx),
)

Expand All @@ -67,12 +69,12 @@ def test_tx_size_too_large(self):
self.nodes[0].settxfee(0.01)
assert_raises_rpc_error(
-6,
"Fee exceeds maximum configured by -maxtxfee",
MAX_FEE_EXCEEDED_MSG,
lambda: self.nodes[0].sendmany(dummy="", amounts=outputs),
)
assert_raises_rpc_error(
-4,
"Fee exceeds maximum configured by -maxtxfee",
MAX_FEE_EXCEEDED_MSG,
lambda: self.nodes[0].fundrawtransaction(hexstring=raw_tx),
)
self.nodes[0].settxfee(0)
Expand Down

0 comments on commit c763343

Please sign in to comment.