Skip to content

Commit bb271fd

Browse files
committed
Added p2sh-p2wpkh support in funding transactions.
1 parent 4a68c82 commit bb271fd

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

contrib/remote_hsmd/NOTES.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ Some popular tests:
8080
export THETEST=tests/test_connection.py::test_disconnect_fundee
8181
export THETEST=tests/test_connection.py::test_reconnect_signed
8282
export THETEST=tests/test_connection.py::test_reconnect_openingd
83-
export THETEST=tests/test_connection.py::test_shutdown_awaiting_lockin
83+
export THETEST=tests/test_connection.py::test_shutdown_awaiting_lockin
84+
85+
# unilateral_close_info
86+
tests/test_closing.py::test_closing_negotiation_reconnect
87+
tests/test_closing.py::test_permfail
88+
tests/test_closing.py::test_option_upfront_shutdown_script
89+
tests/test_connection.py::test_fee_limits
8490

8591
rust-lightning-signer
8692
----------------------------------------------------------------
@@ -101,3 +107,7 @@ p2wsh
101107
p2shwsh
102108
```
103109

110+
111+
```
112+
113+
```

contrib/remote_hsmd/hsmd.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ static struct io_plan *init_hsm(struct io_conn *conn,
757757
"proxy_%s error: %s", __FUNCTION__,
758758
proxy_last_message());
759759
}
760-
g_proxy_impl = PROXY_IMPL_MARSHALED;
760+
g_proxy_impl = PROXY_IMPL_IGNORE;
761761

762762
/*~ We don't need the hsm_secret encryption key anymore.
763763
* Note that sodium_munlock() also zeroes the memory. */
@@ -1021,7 +1021,7 @@ static struct io_plan *handle_sign_commitment_tx(struct io_conn *conn,
10211021
return bad_req_fmt(conn, c, msg_in,
10221022
"proxy_%s error: %s", __FUNCTION__,
10231023
proxy_last_message());
1024-
g_proxy_impl = PROXY_IMPL_MARSHALED;
1024+
g_proxy_impl = PROXY_IMPL_COMPLETE;
10251025

10261026
return req_reply(conn, c,
10271027
take(towire_hsm_sign_commitment_tx_reply(NULL, &sig)));
@@ -1171,7 +1171,7 @@ static struct io_plan *handle_sign_delayed_payment_to_us(struct io_conn *conn,
11711171
return bad_req_fmt(conn, c, msg_in,
11721172
"proxy_%s error: %s", __FUNCTION__,
11731173
proxy_last_message());
1174-
g_proxy_impl = PROXY_IMPL_MARSHALED;
1174+
g_proxy_impl = PROXY_IMPL_COMPLETE;
11751175

11761176
return req_reply(conn, c, take(towire_hsm_sign_tx_reply(NULL, &sig)));
11771177
}
@@ -1656,13 +1656,12 @@ static struct io_plan *handle_sign_withdrawal_tx(struct io_conn *conn,
16561656
cast_const2(const struct utxo **, utxos), outputs,
16571657
&changekey, change_out, NULL, NULL, nlocktime);
16581658

1659-
/* FIXME - There are two things we can't do remotely yet:
1660-
* 1. Handle P2SH inputs.
1659+
/* FIXME - There are things we can't do remotely yet:
16611660
* 2. Handle inputs w/ close_info.
16621661
*/
16631662
bool demure = false;
16641663
for (size_t ii = 0; ii < tx->wtx->num_inputs; ii++)
1665-
if (utxos[ii]->is_p2sh || utxos[ii]->close_info)
1664+
if (utxos[ii]->close_info)
16661665
demure = true;
16671666

16681667
if (!demure) {
@@ -1690,6 +1689,16 @@ static struct io_plan *handle_sign_withdrawal_tx(struct io_conn *conn,
16901689
const struct utxo *in = utxos[ii];
16911690
hsm_key_for_utxo(NULL, &inkey, in);
16921691
pubkey_to_der(der_pubkey, &inkey);
1692+
1693+
if (in->is_p2sh) {
1694+
u8 *script = bitcoin_scriptsig_p2sh_p2wpkh(
1695+
tx, &inkey);
1696+
bitcoin_tx_input_set_script(tx, ii, script);
1697+
1698+
} else {
1699+
bitcoin_tx_input_set_script(tx, ii, NULL);
1700+
}
1701+
16931702
u8 **witness = tal_arr(tx, u8 *, 2);
16941703
witness[0] = tal_dup_arr(witness, u8,
16951704
sigs[ii],

0 commit comments

Comments
 (0)