Helper function to set up a node with BIP86 support using a mnemonic-based HSM secret
(node_factory, mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")
| 1750 | |
| 1751 | |
| 1752 | def setup_bip86_node(node_factory, mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"): |
| 1753 | """Helper function to set up a node with BIP86 support using a mnemonic-based HSM secret""" |
| 1754 | l1 = node_factory.get_node(start=False) |
| 1755 | |
| 1756 | # Set up node with a mnemonic HSM secret |
| 1757 | hsm_path = os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, "hsm_secret") |
| 1758 | if os.path.exists(hsm_path): |
| 1759 | os.remove(hsm_path) |
| 1760 | |
| 1761 | # Generate hsm_secret with the specified mnemonic |
| 1762 | hsmtool = HsmTool(node_factory.directory, "generatehsm", hsm_path) |
| 1763 | master_fd, slave_fd = os.openpty() |
| 1764 | hsmtool.start(stdin=slave_fd) |
| 1765 | hsmtool.wait_for_log(r"Introduce your BIP39 word list") |
| 1766 | write_all(master_fd, f"{mnemonic}\n".encode("utf-8")) |
| 1767 | hsmtool.wait_for_log(r"Enter your passphrase:") |
| 1768 | write_all(master_fd, "\n".encode("utf-8")) # No passphrase |
| 1769 | assert hsmtool.proc.wait(WAIT_TIMEOUT) == 0 |
| 1770 | os.close(master_fd) |
| 1771 | os.close(slave_fd) |
| 1772 | |
| 1773 | l1.start() |
| 1774 | return l1 |
| 1775 | |
| 1776 | |
| 1777 | @unittest.skipIf(TEST_NETWORK != 'regtest', "BIP86 tests are regtest-specific") |
no test coverage detected