tadd BIP9 and segwit_support methods - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 9c70540a2fe04019975aa945a3aa5fe4d6efe7e1 DIR parent 6548388b0e73329e9859afaf434891ac638433d8 HTML Author: ThomasV <thomasv@electrum.org> Date: Sat, 25 Mar 2017 11:09:24 +0100 add BIP9 and segwit_support methods Diffstat: M lib/blockchain.py | 8 ++++++++ 1 file changed, 8 insertions(+), 0 deletions(-) --- DIR diff --git a/lib/blockchain.py b/lib/blockchain.py t@@ -175,6 +175,14 @@ class Blockchain(util.PrintError): h = self.deserialize_header(h, block_height) return h + def BIP9(self, height, flag): + v = self.read_header(height)['version'] + return ((v & 0xE0000000) == 0x20000000) and ((v & flag) == flag) + + def segwit_support(self, N=144): + h = self.local_height + return sum([self.BIP9(h-i, 2) for i in range(N)])*10000/N/100. + def check_truncate_headers(self): checkpoint = self.read_header(self.checkpoint_height) if checkpoint is None: