|
10 | 10 | #include <common/memleak.h> |
11 | 11 | #include <common/overflows.h> |
12 | 12 | #include <common/peer_billboard.h> |
| 13 | +#include <common/psbt_internal.h> |
13 | 14 | #include <common/status.h> |
14 | 15 | #include <common/subdaemon.h> |
15 | 16 | #include <common/type_to_string.h> |
@@ -659,35 +660,6 @@ static u8 *penalty_to_us(const tal_t *ctx, |
659 | 660 | tx, wscript); |
660 | 661 | } |
661 | 662 |
|
662 | | -static void add_keypath_item_to_last_output(struct bitcoin_tx *tx, |
663 | | - u32 index, |
664 | | - const struct ext_key *ext) { |
665 | | - // Skip if there is no wallet keypath for this output. |
666 | | - if (index == UINT32_MAX) |
667 | | - return; |
668 | | - |
669 | | - size_t outndx = tx->psbt->num_outputs - 1; |
670 | | - struct wally_map *map_in = &tx->psbt->outputs[outndx].keypaths; |
671 | | - |
672 | | - u8 fingerprint[BIP32_KEY_FINGERPRINT_LEN]; |
673 | | - if (bip32_key_get_fingerprint( |
674 | | - (struct ext_key *) ext, fingerprint, sizeof(fingerprint)) != WALLY_OK) { |
675 | | - abort(); |
676 | | - } |
677 | | - |
678 | | - u32 path[1]; |
679 | | - path[0] = index; |
680 | | - |
681 | | - tal_wally_start(); |
682 | | - if (wally_map_add_keypath_item(map_in, |
683 | | - ext->pub_key, sizeof(ext->pub_key), |
684 | | - fingerprint, sizeof(fingerprint), |
685 | | - path, 1) != WALLY_OK) { |
686 | | - abort(); |
687 | | - } |
688 | | - tal_wally_end(tx->psbt); |
689 | | -} |
690 | | - |
691 | 663 | /* |
692 | 664 | * This covers: |
693 | 665 | * 1. to-us output spend (`<local_delayedsig> 0`) |
@@ -723,7 +695,7 @@ static struct bitcoin_tx *tx_to_us(const tal_t *ctx, |
723 | 695 |
|
724 | 696 | bitcoin_tx_add_output( |
725 | 697 | tx, scriptpubkey_p2wpkh(tx, &our_wallet_pubkey), NULL, out->sat); |
726 | | - add_keypath_item_to_last_output(tx, our_wallet_index, &our_wallet_ext_key); |
| 698 | + psbt_add_keypath_to_last_output(tx, our_wallet_index, &our_wallet_ext_key); |
727 | 699 |
|
728 | 700 | /* Worst-case sig is 73 bytes */ |
729 | 701 | weight = bitcoin_tx_weight(tx) + 1 + 3 + 73 + 0 + tal_count(wscript); |
@@ -850,7 +822,7 @@ replace_penalty_tx_to_us(const tal_t *ctx, |
850 | 822 | &our_wallet_pubkey), |
851 | 823 | NULL, |
852 | 824 | output_amount); |
853 | | - add_keypath_item_to_last_output(tx, our_wallet_index, &our_wallet_ext_key); |
| 825 | + psbt_add_keypath_to_last_output(tx, our_wallet_index, &our_wallet_ext_key); |
854 | 826 | } |
855 | 827 | else |
856 | 828 | bitcoin_tx_add_output(tx, |
|
0 commit comments