MCPcopy Create free account
hub / github.com/ElementsProject/lightning / setup_bip86_node

Function setup_bip86_node

tests/test_wallet.py:1752–1774  ·  view source on GitHub ↗

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")

Source from the content-addressed store, hash-verified

1750
1751
1752def 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")

Calls 10

HsmToolClass · 0.85
joinMethod · 0.80
wait_for_logMethod · 0.80
write_allFunction · 0.70
get_nodeMethod · 0.45
removeMethod · 0.45
startMethod · 0.45
encodeMethod · 0.45
waitMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected