Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate newaddress p2sh #5751

Merged
merged 4 commits into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cln-grpc/proto/node.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions cln-rpc/src/model.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

234 changes: 117 additions & 117 deletions contrib/pyln-testing/pyln/testing/node_pb2.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contrib/pyln-testing/pyln/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ def connect(self, remote_node):
def is_connected(self, remote_node):
return remote_node.info['id'] in [p['id'] for p in self.rpc.listpeers()['peers']]

def openchannel(self, remote_node, capacity=FUNDAMOUNT, addrtype="p2sh-segwit", confirm=True, wait_for_announce=True, connect=True):
def openchannel(self, remote_node, capacity=FUNDAMOUNT, addrtype="bech32", confirm=True, wait_for_announce=True, connect=True):
addr, wallettxid = self.fundwallet(10 * capacity, addrtype)

if connect and not self.is_connected(remote_node):
Expand All @@ -859,7 +859,7 @@ def openchannel(self, remote_node, capacity=FUNDAMOUNT, addrtype="p2sh-segwit",

return {'address': addr, 'wallettxid': wallettxid, 'fundingtx': res['tx']}

def fundwallet(self, sats, addrtype="p2sh-segwit", mine_block=True):
def fundwallet(self, sats, addrtype="bech32", mine_block=True):
addr = self.rpc.newaddr(addrtype)[addrtype]
txid = self.bitcoin.rpc.sendtoaddress(addr, sats / 10**8)
if mine_block:
Expand Down
12 changes: 5 additions & 7 deletions doc/lightning-newaddr.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ lightning-newaddr -- Command for generating a new address to be used by Core Lig
SYNOPSIS
--------

**newaddr** [ *addresstype* ]
**newaddr** [*addresstype*]

DESCRIPTION
-----------
Expand All @@ -14,12 +14,10 @@ subsequently be used to fund channels managed by the Core Lightning node.

The funding transaction needs to be confirmed before funds can be used.

*addresstype* specifies the type of address wanted; i.e. *p2sh-segwit*
(e.g. `2MxaozoqWwiUcuD9KKgUSrLFDafLqimT9Ta` on bitcoin testnet or
`3MZxzq3jBSKNQ2e7dzneo9hy4FvNzmMmt3` on bitcoin mainnet) or *bech32*
*addresstype* specifies the type of address wanted; currently *bech32*
(e.g. `tb1qu9j4lg5f9rgjyfhvfd905vw46eg39czmktxqgg` on bitcoin testnet
or `bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej` on
bitcoin mainnet). The special value *all* generates both address types
bitcoin mainnet). The special value *all* generates all known address types
for the same underlying key.

If no *addresstype* is specified the address generated is a *bech32* address.
Expand All @@ -33,7 +31,7 @@ RETURN VALUE
On success, an object is returned, containing:

- **bech32** (string, optional): The bech32 (native segwit) address
- **p2sh-segwit** (string, optional): The p2sh-wrapped address
- **p2sh-segwit** (string, optional): The p2sh-wrapped address **deprecated, removal in v23.11**

[comment]: # (GENERATE-FROM-SCHEMA-END)

Expand All @@ -58,4 +56,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:8ed49212ffddf29077007efe38a6b6446cc9c351cb24a1454030526c89407175)
[comment]: # ( SHA256STAMP:9d8dc613c005127a0807f2c8b26b0a96ddc5bf3ebdfa59c3f95a888476c0ce2a)
1 change: 0 additions & 1 deletion doc/schemas/newaddr.request.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"type": "string",
"enum": [
"bech32",
"p2sh-segwit",
"all"
]
}
Expand Down
1 change: 1 addition & 0 deletions doc/schemas/newaddr.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"description": "The bech32 (native segwit) address"
},
"p2sh-segwit": {
"deprecated": "v23.02",
"type": "string",
"description": "The p2sh-wrapped address"
}
Expand Down
8 changes: 4 additions & 4 deletions tests/test_bookkeeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,13 @@ def _check_events(node, channel_id, exp_events):

# l1 events
exp_events = [('channel_open', open_amt * 1000 + lease_fee, 0),
('onchain_fee', 1408000, 0),
('onchain_fee', 1224000, 0),
('lease_fee', 0, lease_fee),
('journal_entry', 0, invoice_msat)]
_check_events(l1, channel_id, exp_events)

exp_events = [('channel_open', open_amt * 1000, 0),
('onchain_fee', 980000, 0),
('onchain_fee', 796000, 0),
('lease_fee', lease_fee, 0),
('journal_entry', invoice_msat, 0)]
_check_events(l2, channel_id, exp_events)
Expand Down Expand Up @@ -455,7 +455,7 @@ def _check_events(node, channel_id, exp_events):

# l1 events
exp_events = [('channel_open', open_amt * 1000, 0),
('onchain_fee', 5257000, 0),
('onchain_fee', 4567000, 0),
('pushed', 0, push_amt),
('journal_entry', 0, invoice_msat)]
_check_events(l1, channel_id, exp_events)
Expand Down Expand Up @@ -528,7 +528,7 @@ def _check_events(node, channel_id, exp_events):

# l1 events
exp_events = [('channel_open', open_amt * 1000, 0),
('onchain_fee', 5257000, 0),
('onchain_fee', 4567000, 0),
('invoice', 0, invoice_msat)]
_check_events(l1, channel_id, exp_events)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_invoice(node_factory, chainparams):
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts={'log-level': 'io'})

addr1 = l2.rpc.newaddr('bech32')['bech32']
addr2 = l2.rpc.newaddr('p2sh-segwit')['p2sh-segwit']
addr2 = '2MxqzNANJNAdMjHQq8ZLkwzooxAFiRzXvEz' if not chainparams['elements'] else 'XGx1E2JSTLZLmqYMAo3CGpsco85aS7so33'
rustyrussell marked this conversation as resolved.
Show resolved Hide resolved
before = int(time.time())
inv = l1.rpc.invoice(123000, 'label', 'description', 3700, [addr1, addr2])

Expand Down
12 changes: 4 additions & 8 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ def dont_spend_outputs(n, txid):
dont_spend_outputs(l1, out['txid'])

# Now send some money to l2.
# lightningd uses P2SH-P2WPKH
waddr = l2.rpc.newaddr('bech32')['bech32']
out = l1.rpc.withdraw(waddr, amount)
bitcoind.generate_block(1)
Expand Down Expand Up @@ -1199,7 +1198,7 @@ def test_blockchaintrack(node_factory, bitcoind):
"""Check that we track the blockchain correctly across reorgs
"""
l1 = node_factory.get_node(random_hsm=True)
addr = l1.rpc.newaddr(addresstype='all')['p2sh-segwit']
addr = l1.rpc.newaddr(addresstype='all')['bech32']

######################################################################
# First failure scenario: rollback on startup doesn't work,
Expand All @@ -1214,7 +1213,7 @@ def test_blockchaintrack(node_factory, bitcoind):
time.sleep(1) # mempool is still unpredictable
bitcoind.generate_block(1)

l1.daemon.wait_for_log(r'Owning output.* \(P2SH\).* CONFIRMED')
l1.daemon.wait_for_log(r'Owning output.* CONFIRMED')
outputs = l1.rpc.listfunds()['outputs']
assert len(outputs) == 1

Expand Down Expand Up @@ -1857,14 +1856,11 @@ def test_bad_onion_immediate_peer(node_factory, bitcoind):

def test_newaddr(node_factory, chainparams):
l1 = node_factory.get_node()
p2sh = l1.rpc.newaddr('p2sh-segwit')
assert 'bech32' not in p2sh
assert p2sh['p2sh-segwit'].startswith(chainparams['p2sh_prefix'])
bech32 = l1.rpc.newaddr('bech32')
assert 'p2sh-segwit' not in bech32
assert bech32['bech32'].startswith(chainparams['bip173_prefix'])
both = l1.rpc.newaddr('all')
assert both['p2sh-segwit'].startswith(chainparams['p2sh_prefix'])
assert 'p2sh-segwit' not in both
assert both['bech32'].startswith(chainparams['bip173_prefix'])


Expand Down Expand Up @@ -2974,7 +2970,7 @@ def test_field_filter(node_factory, chainparams):
l1, l2 = node_factory.get_nodes(2)

addr1 = l1.rpc.newaddr('bech32')['bech32']
addr2 = l1.rpc.newaddr('p2sh-segwit')['p2sh-segwit']
addr2 = '2MxqzNANJNAdMjHQq8ZLkwzooxAFiRzXvEz' if not chainparams['elements'] else 'XGx1E2JSTLZLmqYMAo3CGpsco85aS7so33'
inv = l1.rpc.invoice(123000, 'label', 'description', 3700, [addr1, addr2])

# Simple case: single field
Expand Down
10 changes: 5 additions & 5 deletions tests/test_opening.py
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ def test_funder_options(node_factory, bitcoind):
l3.fundchannel(l1, 10**6)
chan_info = only_one(l3.rpc.listpeerchannels(l1.info['id'])['channels'])
# l1 contributed all its funds!
assert chan_info['funding']['remote_funds_msat'] == Millisatoshi('9994255000msat')
assert chan_info['funding']['remote_funds_msat'] == Millisatoshi('9994945000msat')
assert chan_info['funding']['local_funds_msat'] == Millisatoshi('1000000000msat')


Expand Down Expand Up @@ -1189,7 +1189,7 @@ def test_funder_contribution_limits(node_factory, bitcoind):
'fuzz_percent': 0,
'leases_only': False})

# Set our contribution to 50k sat, should only use 7 of 12 available utxos
# Set our contribution to 50k sat, should only use 6 of 12 available utxos
l3.rpc.call('funderupdate',
{'policy': 'fixed',
'policy_mod': '50000sat',
Expand All @@ -1202,13 +1202,13 @@ def test_funder_contribution_limits(node_factory, bitcoind):

l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
l1.fundchannel(l2, 10**7)
assert l2.daemon.is_in_log('Policy .* returned funding amount of 139020sat')
assert l2.daemon.is_in_log('Policy .* returned funding amount of 141780sat')
assert l2.daemon.is_in_log(r'calling `signpsbt` .* 6 inputs')

l1.rpc.connect(l3.info['id'], 'localhost', l3.port)
l1.fundchannel(l3, 10**7)
assert l3.daemon.is_in_log('Policy .* returned funding amount of 50000sat')
assert l3.daemon.is_in_log(r'calling `signpsbt` .* 7 inputs')
assert l3.daemon.is_in_log(r'calling `signpsbt` .* 6 inputs')


@pytest.mark.openchannel('v2')
Expand Down Expand Up @@ -1395,7 +1395,7 @@ def test_zeroconf_public(bitcoind, node_factory, chainparams):
assert('short_channel_id' not in l2chan)

# Channel is "proposed"
chan_val = 993198000 if chainparams['elements'] else 995673000
chan_val = 993888000 if chainparams['elements'] else 996363000
l1_mvts = [
{'type': 'chain_mvt', 'credit_msat': chan_val, 'debit_msat': 0, 'tags': ['channel_proposed', 'opener']},
{'type': 'channel_mvt', 'credit_msat': 0, 'debit_msat': 20000000, 'tags': ['pushed'], 'fees_msat': '0msat'},
Expand Down
53 changes: 18 additions & 35 deletions tests/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,10 @@ def test_txprepare(node_factory, bitcoind, chainparams):
l1 = node_factory.get_node(random_hsm=True)
addr = chainparams['example_addr']

# Add some funds to withdraw later: both bech32 and p2sh
for i in range(5):
# Add some funds to withdraw later
for i in range(10):
bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'],
amount / 10**8)
bitcoind.rpc.sendtoaddress(l1.rpc.newaddr('p2sh-segwit')['p2sh-segwit'],
amount / 10**8)

bitcoind.generate_block(1)
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 10)
Expand Down Expand Up @@ -448,14 +446,11 @@ def test_reserveinputs(node_factory, bitcoind, chainparams):
l1 = node_factory.get_node(feerates=(7500, 7500, 7500, 7500))

outputs = []
# Add a medley of funds to withdraw later, bech32 + p2sh-p2wpkh
for i in range(total_outs // 2):
# Add a medley of funds to withdraw
for i in range(total_outs):
txid = bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'],
amount / 10**8)
outputs.append((txid, bitcoind.rpc.gettransaction(txid)['details'][0]['vout']))
txid = bitcoind.rpc.sendtoaddress(l1.rpc.newaddr('p2sh-segwit')['p2sh-segwit'],
amount / 10**8)
outputs.append((txid, bitcoind.rpc.gettransaction(txid)['details'][0]['vout']))

bitcoind.generate_block(1)
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == total_outs)
Expand Down Expand Up @@ -504,14 +499,11 @@ def test_fundpsbt(node_factory, bitcoind, chainparams):
l1 = node_factory.get_node()

outputs = []
# Add a medley of funds to withdraw later, bech32 + p2sh-p2wpkh
for i in range(total_outs // 2):
# Add a medley of funds to withdraw later
for i in range(total_outs):
txid = bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'],
amount / 10**8)
outputs.append((txid, bitcoind.rpc.gettransaction(txid)['details'][0]['vout']))
txid = bitcoind.rpc.sendtoaddress(l1.rpc.newaddr('p2sh-segwit')['p2sh-segwit'],
amount / 10**8)
outputs.append((txid, bitcoind.rpc.gettransaction(txid)['details'][0]['vout']))

bitcoind.generate_block(1)
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == total_outs)
Expand Down Expand Up @@ -589,13 +581,11 @@ def test_utxopsbt(node_factory, bitcoind, chainparams):
l1 = node_factory.get_node()

outputs = []
# Add a medley of funds to withdraw later, bech32 + p2sh-p2wpkh
txid = bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'],
amount / 10**8)
outputs.append((txid, bitcoind.rpc.gettransaction(txid)['details'][0]['vout']))
txid = bitcoind.rpc.sendtoaddress(l1.rpc.newaddr('p2sh-segwit')['p2sh-segwit'],
amount / 10**8)
outputs.append((txid, bitcoind.rpc.gettransaction(txid)['details'][0]['vout']))
# Add a funds to withdraw later
for _ in range(2):
txid = bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'],
amount / 10**8)
outputs.append((txid, bitcoind.rpc.gettransaction(txid)['details'][0]['vout']))

bitcoind.generate_block(1)
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == len(outputs))
Expand Down Expand Up @@ -709,11 +699,10 @@ def test_sign_external_psbt(node_factory, bitcoind, chainparams):
amount = 1000000
total_outs = 4

# Add a medley of funds to withdraw later, bech32 + p2sh-p2wpkh
for i in range(total_outs // 2):
# Add a medley of funds to withdraw later
for i in range(total_outs):
bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'],
amount / 10**8)
bitcoind.rpc.sendtoaddress(l1.rpc.newaddr('p2sh-segwit')['p2sh-segwit'], amount / 10**8)

bitcoind.generate_block(1)
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == total_outs)
Expand Down Expand Up @@ -742,12 +731,10 @@ def test_sign_and_send_psbt(node_factory, bitcoind, chainparams):
addr = chainparams['example_addr']
out_total = Millisatoshi(amount * 3 * 1000)

# Add a medley of funds to withdraw later, bech32 + p2sh-p2wpkh
for i in range(total_outs // 2):
# Add a medley of funds to withdraw later
for i in range(total_outs):
bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'],
amount / 10**8)
bitcoind.rpc.sendtoaddress(l1.rpc.newaddr('p2sh-segwit')['p2sh-segwit'],
amount / 10**8)
bitcoind.generate_block(1)
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == total_outs)

Expand Down Expand Up @@ -808,11 +795,9 @@ def test_sign_and_send_psbt(node_factory, bitcoind, chainparams):
l1.rpc.signpsbt(fullpsbt)

# Queue up another node, to make some PSBTs for us
for i in range(total_outs // 2):
for i in range(total_outs):
bitcoind.rpc.sendtoaddress(l2.rpc.newaddr()['bech32'],
amount / 10**8)
bitcoind.rpc.sendtoaddress(l2.rpc.newaddr('p2sh-segwit')['p2sh-segwit'],
amount / 10**8)
# Create a PSBT using L2
bitcoind.generate_block(1)
wait_for(lambda: len(l2.rpc.listfunds()['outputs']) == total_outs)
Expand Down Expand Up @@ -928,12 +913,10 @@ def test_txsend(node_factory, bitcoind, chainparams):
l1 = node_factory.get_node(random_hsm=True)
addr = chainparams['example_addr']

# Add some funds to withdraw later: both bech32 and p2sh
for i in range(5):
# Add some funds to withdraw later
for i in range(10):
bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'],
amount / 10**8)
bitcoind.rpc.sendtoaddress(l1.rpc.newaddr('p2sh-segwit')['p2sh-segwit'],
amount / 10**8)
bitcoind.generate_block(1)
wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 10)

Expand Down
Loading