MCPcopy Create free account
hub / github.com/ElementsProject/lightning / maybe_notify_new_external_send

Function maybe_notify_new_external_send

wallet/walletrpc.c:955–987  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

953};
954
955static 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
989static void sendpsbt_done(struct bitcoind *bitcoind UNUSED,
990 bool success, const char *msg,

Callers 1

sendpsbt_doneFunction · 0.85

Calls 8

psbt_output_to_externalFunction · 0.85
wallet_can_spendFunction · 0.85
tal_bytelenFunction · 0.85
psbt_output_get_amountFunction · 0.85
new_mvt_account_idFunction · 0.85
wallet_save_chain_mvtFunction · 0.85

Tested by

no test coverage detected