|
9 | 9 | ) |
10 | 10 | from test_framework.address import ( |
11 | 11 | address_to_scriptpubkey, |
| 12 | + p2a, |
12 | 13 | script_to_p2sh, |
13 | 14 | ) |
14 | 15 | from test_framework.test_framework import BitcoinTestFramework |
@@ -100,6 +101,18 @@ def witness_script_test(self): |
100 | 101 | for tx_type in ['P2PKH', 'P2PK']: # these tests are order-independent |
101 | 102 | self.verify_txn_with_witness_script(tx_type) |
102 | 103 |
|
| 104 | + def keyless_signing_test(self): |
| 105 | + self.log.info("Test that keyless 'signing' of pay-to-anchor input succeeds") |
| 106 | + funding_txid = self.send_to_address(p2a(), 49.999) |
| 107 | + spending_tx = self.nodes[0].createrawtransaction( |
| 108 | + [{"txid": funding_txid, "vout": 0}], |
| 109 | + [{getnewdestination()[2]: Decimal("49.998")}]) |
| 110 | + spending_tx_signed = self.nodes[0].signrawtransactionwithkey(spending_tx, [], []) |
| 111 | + self.assert_signing_completed_successfully(spending_tx_signed) |
| 112 | + assert self.nodes[0].testmempoolaccept([spending_tx_signed["hex"]])[0]["allowed"] |
| 113 | + # 'signing' a P2A prevout is a no-op, so signed and unsigned txs shouldn't differ |
| 114 | + assert_equal(spending_tx, spending_tx_signed["hex"]) |
| 115 | + |
103 | 116 | def verify_txn_with_witness_script(self, tx_type): |
104 | 117 | self.log.info("Test with a {} script as the witnessScript".format(tx_type)) |
105 | 118 | embedded_privkey, embedded_pubkey = generate_keypair(wif=True) |
@@ -138,6 +151,7 @@ def invalid_private_key_and_tx(self): |
138 | 151 | def run_test(self): |
139 | 152 | self.successful_signing_test() |
140 | 153 | self.witness_script_test() |
| 154 | + self.keyless_signing_test() |
141 | 155 | self.invalid_sighashtype_test() |
142 | 156 | self.invalid_private_key_and_tx() |
143 | 157 |
|
|
0 commit comments