Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Dec 18, 2019

Wallet transactions have inputs, thus they are witness transactions. So properly set iswitness to true.

This fixes the errors of the following kind:

 test  2019-12-18T14:46:14.457000Z TestFramework (ERROR): Assertion failed 
                                   Traceback (most recent call last):
                                     File "/bitcoin/test/functional/test_framework/test_framework.py", line 112, in main
                                       self.run_test()
                                     File "/bitcoin/test/functional/wallet_basic.py", line 207, in run_test
                                       node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), Decimal('20'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex']))
                                     File "/bitcoin/test/functional/wallet_basic.py", line 48, in check_fee_amount
                                       assert_fee_amount(fee, tx_size, fee_per_byte * 1000)
                                     File "/bitcoin/test/functional/test_framework/util.py", line 39, in assert_fee_amount
                                       raise AssertionError("Fee of %s BTC too low! (Should be %s BTC)" % (str(fee), str(target_fee)))
                                   AssertionError: Fee of 0.00011000 BTC too low! (Should be 0.00019100 BTC)

Full log (with color):

log.colored.txt

Relevant excerpt:

 node2 2019-12-18T14:46:13.427834Z [httpworker.0] [default wallet] Fee Calculation: Fee:11000 Bytes:110 Needed:11000 Tgt:0 (requested 0) Reason:"PayTxFee set" Decay 0.00000: Estimation: (-1 - -1) -nan% 0.0/(0.0 0 mem 0.0 out) Fail: (-1 - -1) -nan% 0.0/(0.0 0 mem 0.0 out) 
 node2 2019-12-18T14:46:13.427867Z [httpworker.0] [default wallet] CommitTransaction: 
                                   CTransaction(hash=cc2d0a7862, ver=2, vin.size=1, vout.size=1, nLockTime=205)
                                       CTxIn(COutPoint(fe5a0c8830, 1), scriptSig=, nSequence=4294967294)
                                       CScriptWitness(30440220072d2f1dd001dc40aadec3c3926360033cc036250d603d957556562569d59958022000ca2f88a49c29075d534c1ed89ee678b6b4e9b5e28a897f37e3b5df6d114dff01, 03a7059f3416e80411ec1e02ecbf3e665fceda21d23a4e84e1559f2ed628da95c2)
                                       CTxOut(nValue=9.99989000, scriptPubKey=001475dafea69b760d8e2024cf0bcd)
 node2 2019-12-18T14:46:13.427954Z [httpworker.0] [default wallet] AddToWallet cc2d0a786278c12034c0d286d1876bfaf10dd19253d8efecaa6621c81baa0030  new 

Raw transaction:

# ./src/bitcoin-cli -datadir=/tmp/test_runner_\342\202\277_\360\237\217\203_20191218_144609/wallet_basic_126/node2/ gettransaction cc2d0a786278c12034c0d286d1876bfaf10dd19253d8efecaa6621c81baa0030
{
  "amount": -9.99989000,
  "fee": -0.00011000,
  "confirmations": 1,
  "blockhash": "16f12dd1747458d905ec81af9dc1d576e011f0e4bc426f1b4559e77dd9d922df",
  "blockheight": 206,
  "blockindex": 1,
  "blocktime": 1576680407,
  "txid": "cc2d0a786278c12034c0d286d1876bfaf10dd19253d8efecaa6621c81baa0030",
  "walletconflicts": [
  ],
  "time": 1576680373,
  "timereceived": 1576680373,
  "bip125-replaceable": "no",
  "details": [
    {
      "address": "bcrt1qwhd0af5mwcxcugpyeu9umng4zewfwug47fhhe7",
      "category": "send",
      "amount": -9.99989000,
      "vout": 0,
      "fee": -0.00011000,
      "abandoned": false
    }
  ],
  "hex": "02000000000101dbada06e823a7eaca640c0248aaa7c145f790299acddfc49f6fdbf30880c5afe0100000000feffffff01089f9a3b0000000016001475dafea69b760d8e2024cf0bcdcd15165c977115024730440220072d2f1dd001dc40aadec3c3926360033cc036250d603d957556562569d59958022000ca2f88a49c29075d534c1ed89ee678b6b4e9b5e28a897f37e3b5df6d114dff012103a7059f3416e80411ec1e02ecbf3e665fceda21d23a4e84e1559f2ed628da95c2cd000000"
}

# ./src/bitcoin-cli -datadir=/tmp/test_runner_\342\202\277_\360\237\217\203_20191218_144609/wallet_basic_126/node2/ decoderawtransaction 02000000000101dbada06e823a7eaca640c0248aaa7c145f790299acddfc49f6fdbf30880c5afe0100000000feffffff01089f9a3b0000000016001475dafea69b760d8e2024cf0bcdcd15165c977115024730440220072d2f1dd001dc40aadec3c3926360033cc036250d603d957556562569d59958022000ca2f88a49c29075d534c1ed89ee678b6b4e9b5e28a897f37e3b5df6d114dff012103a7059f3416e80411ec1e02ecbf3e665fceda21d23a4e84e1559f2ed628da95c2cd000000
{
  "txid": "658ee42c79f167c7ad21071773ca008d71e73cd42a36d6da0b66651b6d203a00",
  "hash": "658ee42c79f167c7ad21071773ca008d71e73cd42a36d6da0b66651b6d203a00",
  "version": 2,
  "size": 191,
  "vsize": 191,
  "weight": 764,
  "locktime": 205,
  "vin": [
  ],
  "vout": [
    {
      "value": 90957258090.81899777,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_RIPEMD160 c0248aaa7c145f790299acddfc49f6fdbf30880c5afe0100000000feffffff01089f9a3b0000000016001475dafea69b760d8e2024cf0bcdcd15165c97711502 30440220072d2f1dd001dc40aadec3c3926360033cc036250d603d957556562569d59958022000ca2f88a49c29075d534c1ed89ee678b6b4e9b5e28a897f37e3b5df6d114dff01 03a7059f3416e80411ec1e02ecbf3e665fceda21d23a4e84e1559f2ed628da95c2",
        "hex": "a640c0248aaa7c145f790299acddfc49f6fdbf30880c5afe0100000000feffffff01089f9a3b0000000016001475dafea69b760d8e2024cf0bcdcd15165c977115024730440220072d2f1dd001dc40aadec3c3926360033cc036250d603d957556562569d59958022000ca2f88a49c29075d534c1ed89ee678b6b4e9b5e28a897f37e3b5df6d114dff012103a7059f3416e80411ec1e02ecbf3e665fceda21d23a4e84e1559f2ed628da95c2",
        "type": "nonstandard"
      }
    }
  ]
}

# ./src/bitcoin-cli -datadir=/tmp/test_runner_\342\202\277_\360\237\217\203_20191218_144609/wallet_basic_126/node2/ decoderawtransaction 02000000000101dbada06e823a7eaca640c0248aaa7c145f790299acddfc49f6fdbf30880c5afe0100000000feffffff01089f9a3b0000000016001475dafea69b760d8e2024cf0bcdcd15165c977115024730440220072d2f1dd001dc40aadec3c3926360033cc036250d603d957556562569d59958022000ca2f88a49c29075d534c1ed89ee678b6b4e9b5e28a897f37e3b5df6d114dff012103a7059f3416e80411ec1e02ecbf3e665fceda21d23a4e84e1559f2ed628da95c2cd000000 | grep vsize
  "vsize": 191,


# ./src/bitcoin-cli -datadir=/tmp/test_runner_\342\202\277_\360\237\217\203_20191218_144609/wallet_basic_126/node2/ decoderawtransaction 02000000000101dbada06e823a7eaca640c0248aaa7c145f790299acddfc49f6fdbf30880c5afe0100000000feffffff01089f9a3b0000000016001475dafea69b760d8e2024cf0bcdcd15165c977115024730440220072d2f1dd001dc40aadec3c3926360033cc036250d603d957556562569d59958022000ca2f88a49c29075d534c1ed89ee678b6b4e9b5e28a897f37e3b5df6d114dff012103a7059f3416e80411ec1e02ecbf3e665fceda21d23a4e84e1559f2ed628da95c2cd000000 true | grep vsize
  "vsize": 110,



@fanquake fanquake added the Tests label Dec 18, 2019
@DrahtBot
Copy link
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #17566 (Switch to weight units for all feerates computation by darosior)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@maflcko maflcko changed the title test: Fix rare error in wallet_basic test for witness transactions test: Properly deserialize witness transactions in wallet_basic test Dec 19, 2019
@instagibbs
Copy link
Member

@MarcoFalke How about #17775 instead?

@maflcko maflcko closed this Dec 19, 2019
@maflcko maflcko deleted the 1912-testWalletVsizeWitness branch December 19, 2019 16:54
laanwj added a commit that referenced this pull request Oct 15, 2020
27fc6a3 DecodeHexTx: Break out transaction decoding logic into own function (Gregory Sanders)
6020ce3 DecodeHexTx: Try case where txn has inputs first (Gregory Sanders)

Pull request description:

  Alternative/complementary to #17773 to avoid random `decoderawtransaction` failures. Most cases this is used now is on complete transactions, especially with the uptake of PSBT.

ACKs for top commit:
  ajtowns:
    ACK 27fc6a3
  achow101:
    ACK 27fc6a3

Tree-SHA512: 0a836d7c9951bf7d2764507788dbcc871d520f1ea9b77d6b22f051f4d6224ed779aba0e4f28c5c165040095ee0c70b67080c39164d82de61b19158f7ae6fddb2
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 16, 2020
27fc6a3 DecodeHexTx: Break out transaction decoding logic into own function (Gregory Sanders)
6020ce3 DecodeHexTx: Try case where txn has inputs first (Gregory Sanders)

Pull request description:

  Alternative/complementary to bitcoin#17773 to avoid random `decoderawtransaction` failures. Most cases this is used now is on complete transactions, especially with the uptake of PSBT.

ACKs for top commit:
  ajtowns:
    ACK 27fc6a3
  achow101:
    ACK 27fc6a3

Tree-SHA512: 0a836d7c9951bf7d2764507788dbcc871d520f1ea9b77d6b22f051f4d6224ed779aba0e4f28c5c165040095ee0c70b67080c39164d82de61b19158f7ae6fddb2
@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.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants