| 953 | }; |
| 954 | |
| 955 | static void maybe_notify_new_external_send(struct lightningd *ld, |
| 956 | struct bitcoin_txid *txid, |
| 957 | u32 outnum, |
| 958 | struct wally_psbt *psbt) |
| 959 | { |
| 960 | struct chain_coin_mvt *mvt; |
| 961 | struct bitcoin_outpoint outpoint; |
| 962 | struct amount_sat amount; |
| 963 | u32 index; |
| 964 | const u8 *script; |
| 965 | |
| 966 | /* If it's not going to an external address, ignore */ |
| 967 | if (!psbt_output_to_external(&psbt->outputs[outnum])) |
| 968 | return; |
| 969 | |
| 970 | /* If it's going to our wallet, ignore */ |
| 971 | script = wally_psbt_output_get_script(tmpctx, |
| 972 | &psbt->outputs[outnum]); |
| 973 | if (wallet_can_spend(ld->wallet, script, tal_bytelen(script), &index, NULL)) |
| 974 | return; |
| 975 | |
| 976 | outpoint.txid = *txid; |
| 977 | outpoint.n = outnum; |
| 978 | amount = psbt_output_get_amount(psbt, outnum); |
| 979 | |
| 980 | mvt = new_coin_external_deposit(NULL, &outpoint, |
| 981 | 0, amount, |
| 982 | mk_mvt_tags(MVT_DEPOSIT)); |
| 983 | |
| 984 | mvt->originating_acct = new_mvt_account_id(mvt, NULL, ACCOUNT_NAME_WALLET); |
| 985 | |
| 986 | wallet_save_chain_mvt(ld, take(mvt)); |
| 987 | } |
| 988 | |
| 989 | static void sendpsbt_done(struct bitcoind *bitcoind UNUSED, |
| 990 | bool success, const char *msg, |
no test coverage detected