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