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

Expose a transaction's weight via RPC #12791

merged 3 commits into from Apr 17, 2018
Changes from 1 commit
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+4 −1
Diff settings


Just for now

Test new weight field in p2p_segwit

  • Loading branch information...
TheBlueMatt committed Mar 27, 2018
commit d0d9112b79f8c08971dd140143306ca497c47de7
Copy path View file
@@ -10,6 +10,7 @@
from test_framework.script import *
from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment, get_witness_script, WITNESS_COMMITMENT_HEADER
from test_framework.key import CECKey, CPubKey
import math
import time
import random
from binascii import hexlify
@@ -930,8 +931,10 @@ def test_tx_relay_after_segwit_activation(self):
raw_tx = self.nodes[0].getrawtransaction(tx3.hash, 1)
assert_equal(int(raw_tx["hash"], 16), tx3.calc_sha256(True))
assert_equal(raw_tx["size"], len(tx3.serialize_with_witness()))
vsize = (len(tx3.serialize_with_witness()) + 3*len(tx3.serialize_without_witness()) + 3) / 4
weight = len(tx3.serialize_with_witness()) + 3*len(tx3.serialize_without_witness())
vsize = math.ceil(weight / 4)
assert_equal(raw_tx["vsize"], vsize)
assert_equal(raw_tx["weight"], weight)
assert_equal(len(raw_tx["vin"][0]["txinwitness"]), 1)
assert_equal(raw_tx["vin"][0]["txinwitness"][0], hexlify(witness_program).decode('ascii'))
assert(vsize != raw_tx["size"])
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.