Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wallet, rpc tests] Fix settxfee, paytxfee #7103

Merged
merged 2 commits into from Nov 30, 2015

Conversation

MarcoFalke
Copy link
Member

This comes without the GUI changes, so it should be easier to review and backport. GUI: #7096


#check if JSON parser can handle scientific notation in strings
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), "1e-4")
txObj = self.nodes[0].gettransaction(txId)
assert_equal(txObj['amount'], Decimal('-0.00010000'))
assert_equal(txObj['amount'], Decimal('-0.0001'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does removing the extra zeroes here make any difference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>>> Decimal("0.100") == Decimal(".1")
True

But the diff is larger. So removed this.

@@ -67,6 +67,9 @@ def check_json_precision():
if satoshis != 2000000000000003:
raise RuntimeError("JSON encode/decode loses precision")

def count_bytes(hex_string):
return len(bytearray.fromhex(hex_string))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm.. is forming a byte arrayreally necessary? Would len(hex_string)/2 not be sufficient?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered that nit, but right now it checks it is a valid hex string, which is kind of useful for a test

@jonasschnelli
Copy link
Contributor

Tested ACK.

Works (tx size 373 bytes, txfeerate is 0.01, fee = 0.00373):

Jonass-MacBook-Pro:_bitcoin jonasschnelli$ ./src/bitcoin-cli --regtest getbalance
47.98861600
Jonass-MacBook-Pro:_bitcoin jonasschnelli$ ./src/bitcoin-cli --regtest settxfee 0.01
true
Jonass-MacBook-Pro:_bitcoin jonasschnelli$ ./src/bitcoin-cli --regtest getnewaddress
n1YGgjMuRDCEL9PDoMXKeEMzE4Z5gYNHKC
Jonass-MacBook-Pro:_bitcoin jonasschnelli$ ./src/bitcoin-cli --regtest sendtoaddress n1YGgjMuRDCEL9PDoMXKeEMzE4Z5gYNHKC 1.0
ccfb9f516f7935fe53d8c8dfbda2ba9f573a516da465124d4a3f02e9afb1c009
Jonass-MacBook-Pro:_bitcoin jonasschnelli$ ./src/bitcoin-cli --regtest gettransaction ccfb9f516f7935fe53d8c8dfbda2ba9f573a516da465124d4a3f02e9afb1c009
{
  "amount": 0.00000000,
  "fee": -0.00373000,
  "confirmations": 0,
  "txid": "ccfb9f516f7935fe53d8c8dfbda2ba9f573a516da465124d4a3f02e9afb1c009",
  "walletconflicts": [
  ],
  "time": 1448546094,
  "timereceived": 1448546094,
  "details": [
    {
      "account": "",
      "address": "n1YGgjMuRDCEL9PDoMXKeEMzE4Z5gYNHKC",
      "category": "send",
      "amount": -1.00000000,
      "label": "",
      "vout": 1,
      "fee": -0.00373000
    }, 
    {
      "account": "",
      "address": "n1YGgjMuRDCEL9PDoMXKeEMzE4Z5gYNHKC",
      "category": "receive",
      "amount": 1.00000000,
      "label": "",
      "vout": 1
    }
  ],
  "hex": "0100000002194adfb873b92507d4004b34910ea2e48f673be6c2d46b2408123e59b581f043000000006a47304402203bc41e34daa2ec5f795c38ef31c6d6fe926682609ebaca41ad50867b810d49b902203028f9334df4415da1f0c12ce76211c70583e853e3bb3158508b973b1b659ab4012102d9ce185100c65ba09aaf0d634fb86632ad73a54ff510f833e00348f4bb9edc47feffffff194adfb873b92507d4004b34910ea2e48f673be6c2d46b2408123e59b581f043010000006b483045022100e7fd9fc3a9e0d3ca6e8724e3daf330a1afe5de801e58c5f2193aaed25723d24d0220503460a151301d304f00b6d16364c9cb128e0005eda24950d6436a5b23a86baf01210339167b46e7774585f439d4780919e2dee5af9023cdef4778e245aa40c7650a04feffffff02e09def05000000001976a914d8d20ef3bdd8a263461b5463673cb901716bd88288ac00e1f505000000001976a914dba2489ddc1bfc465632141b8c5e1f3e1fd4a16888ac5b000000"
}

Tested also together with the UI (known bug/interference still behaves likes expected).

@sipa
Copy link
Member

sipa commented Nov 26, 2015

utACK

1 similar comment
@laanwj
Copy link
Member

laanwj commented Nov 26, 2015

utACK

@laanwj
Copy link
Member

laanwj commented Nov 27, 2015

@gmaxwell can you take a look here too

@laanwj laanwj added this to the 0.12.0 milestone Nov 27, 2015
Ryan Havar and others added 2 commits November 28, 2015 22:51
This allows for much finer control of the transaction fees per kilobyte
as it prevent small transactions using a fee that is more appropriate
for one that is of a kilobyte.

This also allows controlling the fee per kilobyte over rpc such that:

bitcoin-cli settxfee `bitcoin-cli estimatefee 2`

would make sense, while currently it grossly fails often by a factor of x3
@MarcoFalke
Copy link
Member Author

Trivial rebase. (Previous head: fa895cb)

@laanwj laanwj merged commit fa506c0 into bitcoin:master Nov 30, 2015
laanwj added a commit that referenced this pull request Nov 30, 2015
fa506c0 [wallet] Add rpc tests to verify fee calculations (MarcoFalke)
4b89f01 Default fPayAtLeastCustomFee to false (Ryan Havar)
@MarcoFalke MarcoFalke deleted the FixSettxfee branch November 30, 2015 11:22
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants