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

Function run_openchannel

tests/plugins/openchannel_hook_accepter.py:19–50  ·  view source on GitHub ↗
(funding_sats_str, ctype, plugin)

Source from the content-addressed store, hash-verified

17
18
19def run_openchannel(funding_sats_str, ctype, plugin):
20 # Convert from string to satoshis
21 funding_sats = Millisatoshi(funding_sats_str).to_satoshi()
22
23 # - 100005sat: we reject correctly w/o close_to
24 if funding_sats == 100005:
25 msg = "reject for a reason"
26 plugin.log(msg)
27 return {'result': 'reject', 'error_message': msg}
28
29 # - 100004sat: we reject invalid by setting a close_to
30 if funding_sats == 100004:
31 msg = "I am a broken plugin"
32 plugin.log(msg)
33 return {'result': 'reject', 'error_message': msg,
34 'close_to': "bcrt1q7gtnxmlaly9vklvmfj06amfdef3rtnrdazdsvw"}
35
36 # - 100003sat: we send back a valid address (regtest)
37 if funding_sats == 100003:
38 return {'result': 'continue', 'close_to': 'bcrt1q7gtnxmlaly9vklvmfj06amfdef3rtnrdazdsvw'}
39
40 # - 100002sat: we send back an empty address
41 if funding_sats == 100002:
42 return {'result': 'continue', 'close_to': ''}
43
44 # - 100001sat: we send back an address for the wrong chain (mainnet)
45 if funding_sats == 100001:
46 return {'result': 'continue', 'close_to': 'bc1qlq8srqnz64wgklmqvurv7qnr4rvtq2u96hhfg2'}
47
48 # - otherwise: accept and don't include the close_to
49 plugin.log(f"accept by design: channel_type {ctype}")
50 return {'result': 'continue'}
51
52
53@plugin.hook('openchannel')

Callers 2

on_openchannelFunction · 0.85
on_openchannel2Function · 0.85

Calls 3

MillisatoshiClass · 0.90
to_satoshiMethod · 0.80
logMethod · 0.80

Tested by

no test coverage detected