@@ -1148,16 +1148,11 @@ static struct io_plan *handle_sign_remote_htlc_tx(struct io_conn *conn,
11481148 struct client * c ,
11491149 const u8 * msg_in )
11501150{
1151- struct secret channel_seed ;
11521151 struct bitcoin_tx * tx ;
11531152 struct bitcoin_signature sig ;
1154- struct secrets secrets ;
1155- struct basepoints basepoints ;
11561153 struct pubkey remote_per_commit_point ;
11571154 struct amount_sat amount ;
11581155 u8 * wscript ;
1159- struct privkey htlc_privkey ;
1160- struct pubkey htlc_pubkey ;
11611156
11621157 if (!fromwire_hsm_sign_remote_htlc_tx (tmpctx , msg_in ,
11631158 & tx , & wscript , & amount ,
@@ -1185,39 +1180,7 @@ static struct io_plan *handle_sign_remote_htlc_tx(struct io_conn *conn,
11851180 return bad_req_fmt (conn , c , msg_in ,
11861181 "proxy_%s error: %s" , __FUNCTION__ ,
11871182 proxy_last_message ());
1188- g_proxy_impl = PROXY_IMPL_MARSHALED ;
1189-
1190- /* FIXME - server-side not implemented yet. Use original code
1191- * below for now */
1192-
1193- /*
1194- assert(tal_count(sigs) == 1);
1195-
1196- bool ok = signature_from_der(sigs[0][0], tal_count(sigs[0][0]), &sig);
1197- assert(ok);
1198- status_debug("%s:%d %s: signature: %s",
1199- __FILE__, __LINE__, __FUNCTION__,
1200- type_to_string(tmpctx, struct bitcoin_signature, &sig));
1201- */
1202-
1203- get_channel_seed (& c -> id , c -> dbid , & channel_seed );
1204- derive_basepoints (& channel_seed , NULL , & basepoints , & secrets , NULL );
1205-
1206- if (!derive_simple_privkey (& secrets .htlc_basepoint_secret ,
1207- & basepoints .htlc ,
1208- & remote_per_commit_point ,
1209- & htlc_privkey ))
1210- return bad_req_fmt (conn , c , msg_in ,
1211- "Failed deriving htlc privkey" );
1212-
1213- if (!derive_simple_key (& basepoints .htlc ,
1214- & remote_per_commit_point ,
1215- & htlc_pubkey ))
1216- return bad_req_fmt (conn , c , msg_in ,
1217- "Failed deriving htlc pubkey" );
1218-
1219- sign_tx_input (tx , 0 , NULL , wscript , & htlc_privkey , & htlc_pubkey ,
1220- SIGHASH_ALL , & sig );
1183+ g_proxy_impl = PROXY_IMPL_COMPLETE ;
12211184
12221185 return req_reply (conn , c , take (towire_hsm_sign_tx_reply (NULL , & sig )));
12231186}
@@ -2011,11 +1974,7 @@ static struct io_plan *handle_sign_invoice(struct io_conn *conn,
20111974 * entirely transparent to the C compiler. */
20121975 u5 * u5bytes ;
20131976 u8 * hrpu8 ;
2014- char * hrp ;
2015- struct sha256 sha ;
20161977 secp256k1_ecdsa_recoverable_signature rsig ;
2017- struct hash_u5 hu5 ;
2018- struct privkey node_pkey ;
20191978
20201979 if (!fromwire_hsm_sign_invoice (tmpctx , msg_in , & u5bytes , & hrpu8 ))
20211980 return bad_req (conn , c , msg_in );
@@ -2029,46 +1988,7 @@ static struct io_plan *handle_sign_invoice(struct io_conn *conn,
20291988 return bad_req_fmt (conn , c , msg_in ,
20301989 "proxy_%s error: %s" , __FUNCTION__ ,
20311990 proxy_last_message ());
2032- g_proxy_impl = PROXY_IMPL_MARSHALED ;
2033-
2034- /* FIXME - USE THE PROXIED VALUE WHEN SERVER SUPPORTS */
2035-
2036- /* BOLT #11:
2037- *
2038- * A writer... MUST set `signature` to a valid 512-bit
2039- * secp256k1 signature of the SHA2 256-bit hash of the
2040- * human-readable part, represented as UTF-8 bytes,
2041- * concatenated with the data part (excluding the signature)
2042- * with 0 bits appended to pad the data to the next byte
2043- * boundary, with a trailing byte containing the recovery ID
2044- * (0, 1, 2, or 3).
2045- */
2046-
2047- /* FIXME: Check invoice! */
2048-
2049- /*~ tal_dup_arr() does what you'd expect: allocate an array by copying
2050- * another; the cast is needed because the hrp is a 'char' array, not
2051- * a 'u8' (unsigned char) as it's the "human readable" part.
2052- *
2053- * The final arg of tal_dup_arr() is how many extra bytes to allocate:
2054- * it's so often zero that I've thought about dropping the argument, but
2055- * in cases like this (adding a NUL terminator) it's perfect. */
2056- hrp = tal_dup_arr (tmpctx , char , (char * )hrpu8 , tal_count (hrpu8 ), 1 );
2057- hrp [tal_count (hrpu8 )] = '\0' ;
2058-
2059- hash_u5_init (& hu5 , hrp );
2060- hash_u5 (& hu5 , u5bytes , tal_count (u5bytes ));
2061- hash_u5_done (& hu5 , & sha );
2062-
2063- node_key (& node_pkey , NULL );
2064- /*~ By no small coincidence, this libsecp routine uses the exact
2065- * recovery signature format mandated by BOLT 11. */
2066- if (!secp256k1_ecdsa_sign_recoverable (secp256k1_ctx , & rsig ,
2067- (const u8 * )& sha ,
2068- node_pkey .secret .data ,
2069- NULL , NULL )) {
2070- return bad_req_fmt (conn , c , msg_in , "Failed to sign invoice" );
2071- }
1991+ g_proxy_impl = PROXY_IMPL_COMPLETE ;
20721992
20731993 return req_reply (conn , c ,
20741994 take (towire_hsm_sign_invoice_reply (NULL , & rsig )));
0 commit comments