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