| 364 | } |
| 365 | |
| 366 | static void report(struct bitcoin_tx *tx, |
| 367 | const u8 *wscript, |
| 368 | const struct privkey *x_remote_funding_privkey, |
| 369 | const struct pubkey *remote_funding_pubkey, |
| 370 | const struct privkey *local_funding_privkey, |
| 371 | const struct pubkey *local_funding_pubkey, |
| 372 | u16 to_self_delay, |
| 373 | const struct privkey *local_htlcsecretkey, |
| 374 | const struct pubkey *localkey, |
| 375 | const struct pubkey *local_htlckey, |
| 376 | const struct pubkey *local_delayedkey, |
| 377 | const struct privkey *x_remote_htlcsecretkey, |
| 378 | const struct pubkey *remotekey, |
| 379 | const struct pubkey *remote_htlckey, |
| 380 | const struct pubkey *remote_revocation_key, |
| 381 | u32 feerate_per_kw, |
| 382 | bool option_anchor_outputs, |
| 383 | const struct htlc **htlc_map) |
| 384 | { |
| 385 | char *txhex; |
| 386 | struct bitcoin_signature localsig, remotesig; |
| 387 | u8 **witness; |
| 388 | |
| 389 | sign_tx_input(tx, 0, |
| 390 | NULL, |
| 391 | wscript, |
| 392 | x_remote_funding_privkey, remote_funding_pubkey, |
| 393 | SIGHASH_ALL, |
| 394 | &remotesig); |
| 395 | printf("remote_signature = %s\n", |
| 396 | type_to_string(tmpctx, secp256k1_ecdsa_signature, &remotesig.s)); |
| 397 | sign_tx_input(tx, 0, |
| 398 | NULL, |
| 399 | wscript, |
| 400 | local_funding_privkey, local_funding_pubkey, |
| 401 | SIGHASH_ALL, |
| 402 | &localsig); |
| 403 | printf("# local_signature = %s\n", |
| 404 | type_to_string(tmpctx, secp256k1_ecdsa_signature, &localsig.s)); |
| 405 | |
| 406 | witness = |
| 407 | bitcoin_witness_2of2(tx, &localsig, &remotesig, |
| 408 | local_funding_pubkey, remote_funding_pubkey); |
| 409 | bitcoin_tx_input_set_witness(tx, 0, take(witness)); |
| 410 | txhex = tal_hex(tmpctx, linearize_tx(tx, tx)); |
| 411 | printf("output commit_tx: %s\n", txhex); |
| 412 | |
| 413 | report_htlcs(tx, htlc_map, to_self_delay, |
| 414 | local_htlcsecretkey, localkey, local_htlckey, |
| 415 | local_delayedkey, |
| 416 | x_remote_htlcsecretkey, |
| 417 | remotekey, remote_htlckey, |
| 418 | remote_revocation_key, |
| 419 | feerate_per_kw, |
| 420 | option_anchor_outputs); |
| 421 | } |
| 422 | |
| 423 | #ifdef DEBUG |
no test coverage detected