| 819 | }; |
| 820 | |
| 821 | static void maybe_notify_new_external_send(struct lightningd *ld, |
| 822 | struct bitcoin_txid *txid, |
| 823 | u32 outnum, |
| 824 | struct wally_psbt *psbt) |
| 825 | { |
| 826 | struct chain_coin_mvt *mvt; |
| 827 | struct bitcoin_outpoint outpoint; |
| 828 | struct amount_sat amount; |
| 829 | u32 index; |
| 830 | bool is_p2sh; |
| 831 | const u8 *script; |
| 832 | |
| 833 | /* If it's not going to an external address, ignore */ |
| 834 | if (!psbt_output_to_external(&psbt->outputs[outnum])) |
| 835 | return; |
| 836 | |
| 837 | /* If it's going to our wallet, ignore */ |
| 838 | script = wally_tx_output_get_script(tmpctx, |
| 839 | &psbt->tx->outputs[outnum]); |
| 840 | if (wallet_can_spend(ld->wallet, script, &index, &is_p2sh)) |
| 841 | return; |
| 842 | |
| 843 | outpoint.txid = *txid; |
| 844 | outpoint.n = outnum; |
| 845 | amount = psbt_output_get_amount(psbt, outnum); |
| 846 | |
| 847 | mvt = new_coin_external_deposit(NULL, &outpoint, |
| 848 | 0, amount, |
| 849 | DEPOSIT); |
| 850 | |
| 851 | mvt->originating_acct = WALLET; |
| 852 | notify_chain_mvt(ld, mvt); |
| 853 | tal_free(mvt); |
| 854 | } |
| 855 | |
| 856 | |
| 857 | static void sendpsbt_done(struct bitcoind *bitcoind UNUSED, |
no test coverage detected