| 85 | } |
| 86 | |
| 87 | static struct chain_coin_mvt *new_chain_coin_mvt(const tal_t *ctx, |
| 88 | const char *account_name TAKES, |
| 89 | const struct bitcoin_txid *tx_txid, |
| 90 | const struct bitcoin_outpoint *outpoint, |
| 91 | const struct sha256 *payment_hash TAKES, |
| 92 | u32 blockheight, |
| 93 | enum mvt_tag *tags, |
| 94 | struct amount_msat amount, |
| 95 | bool is_credit, |
| 96 | struct amount_sat output_val, |
| 97 | u32 out_count) |
| 98 | { |
| 99 | struct chain_coin_mvt *mvt = tal(ctx, struct chain_coin_mvt); |
| 100 | |
| 101 | if (account_name) |
| 102 | mvt->account_name = tal_strdup(mvt, account_name); |
| 103 | else |
| 104 | mvt->account_name = NULL; |
| 105 | |
| 106 | mvt->tx_txid = tx_txid; |
| 107 | mvt->outpoint = outpoint; |
| 108 | mvt->originating_acct = NULL; |
| 109 | |
| 110 | /* Most chain event's don't have a peer (only channel_opens) */ |
| 111 | mvt->peer_id = NULL; |
| 112 | |
| 113 | /* for htlc's that are filled onchain, we also have a |
| 114 | * preimage, NULL otherwise */ |
| 115 | mvt->payment_hash = tal_dup_or_null(mvt, struct sha256, payment_hash); |
| 116 | mvt->blockheight = blockheight; |
| 117 | |
| 118 | mvt->tags = tal_dup_talarr(mvt, enum mvt_tag, tags); |
| 119 | |
| 120 | if (is_credit) { |
| 121 | mvt->credit = amount; |
| 122 | mvt->debit = AMOUNT_MSAT(0); |
| 123 | } else { |
| 124 | mvt->debit = amount; |
| 125 | mvt->credit = AMOUNT_MSAT(0); |
| 126 | } |
| 127 | |
| 128 | mvt->output_val = output_val; |
| 129 | mvt->output_count = out_count; |
| 130 | |
| 131 | return mvt; |
| 132 | } |
| 133 | |
| 134 | static struct chain_coin_mvt *new_chain_coin_mvt_sat(const tal_t *ctx, |
| 135 | const char *account_name, |
no outgoing calls
no test coverage detected