def test_signing(self): tx_ids = [ 'f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16', '12b5633bad1f9c167d523ad1aa1947b2732a865bf5414eab2f9e5ae5d5c191ba', # P2PK # 'a38d3393a32d06fe842b35ebd68aa2b6a1ccbabbbc244f67462a10fd8c81dba5', # coinbase 'a8d60051745755be5b13ba3ecedc1540fbb66e95ab15e76b4d871fd7c2b68794', # segwit 'fff2525b8931402dd09222c50775608f75787bd2b87e56995a7bdd30f79702c4', 'ee475443f1fbfff84ffba43ba092a70d291df233bd1428f3d09f7bd1a6054a1f', '7edb32d4ffd7a385b763c7a8e56b6358bcd729e747290624e18acdbe6209fc45', # 1-of-1 multisig '001bf3d87e417c63eee64bd466d0a6eec9770a3b336368062e9db730cf5db922', # Spends P2SH 2-of-3 multisig '5a0ce1166ff8e6800416b1aa25f1577e233f230bd21204a6505fa6ee5a9c5fc6', 'ef27d32f7f0c645daec3071c203399783555d84cfe92bfe61583a464a260df0b', # 24 inputs 7 outputs '454e575aa1ed4427985a9732d753b37dc711675eb7c977637b1eea7f600ed214', # sends to P2SH and P2WSH 'eba5e1e668e0d47dc28c7fff686a7f680e334e1f9740fd90f0aed3d5e9c4114a', # spends P2WSH 'e5c95e9b3c8e81bf9fc4da9f069e5c40fa38cdcc0067b5706b517878298a6f7f', # non standard sequence 'e694da982e1a725e3524c622932f6159a328194a9201588783393c35ac852732' # P2SH-P2WSH ] private = PrivateKey.random() for tx_id in tx_ids: tx = Transaction.get(tx_id) for inp in tx.inputs: if inp.ref().type() not in (TX.P2WSH, TX.P2SH): self.assertTrue(inp.is_signed()) inp.clear() self.assertFalse(inp.is_signed()) inp.sign(private) self.assertTrue(inp.is_signed()) self.assertFalse(tx.verify(inp.tx_index))
def test_verification(self): tx_ids = [ 'f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16', '12b5633bad1f9c167d523ad1aa1947b2732a865bf5414eab2f9e5ae5d5c191ba', # P2PK # 'a38d3393a32d06fe842b35ebd68aa2b6a1ccbabbbc244f67462a10fd8c81dba5', # coinbase 'a8d60051745755be5b13ba3ecedc1540fbb66e95ab15e76b4d871fd7c2b68794', # segwit 'fff2525b8931402dd09222c50775608f75787bd2b87e56995a7bdd30f79702c4', 'ee475443f1fbfff84ffba43ba092a70d291df233bd1428f3d09f7bd1a6054a1f', '5a0ce1166ff8e6800416b1aa25f1577e233f230bd21204a6505fa6ee5a9c5fc6', 'ef27d32f7f0c645daec3071c203399783555d84cfe92bfe61583a464a260df0b', # 24 inputs 7 outputs '454e575aa1ed4427985a9732d753b37dc711675eb7c977637b1eea7f600ed214', # sends to P2SH and P2WSH 'eba5e1e668e0d47dc28c7fff686a7f680e334e1f9740fd90f0aed3d5e9c4114a', # spends P2WSH 'e5c95e9b3c8e81bf9fc4da9f069e5c40fa38cdcc0067b5706b517878298a6f7f', # non standard sequence 'e694da982e1a725e3524c622932f6159a328194a9201588783393c35ac852732' # P2SH-P2WSH ] for tx_id in tx_ids: tx = Transaction.get(tx_id) self.assertTrue(tx.verify()) for inp in tx.inputs: self.assertTrue(inp.is_signed())