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

Function maybe_notify_new_external_send

wallet/walletrpc.c:821–854  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

819};
820
821static 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
857static void sendpsbt_done(struct bitcoind *bitcoind UNUSED,

Callers 1

sendpsbt_doneFunction · 0.85

Calls 7

psbt_output_to_externalFunction · 0.85
wallet_can_spendFunction · 0.85
psbt_output_get_amountFunction · 0.85
tal_freeFunction · 0.85
notify_chain_mvtFunction · 0.50

Tested by

no test coverage detected