| 4136 | } |
| 4137 | |
| 4138 | static |
| 4139 | struct wallet_payment *wallet_payment_new(const tal_t *ctx, |
| 4140 | u64 dbid, |
| 4141 | u64 updated_index, |
| 4142 | u32 timestamp, |
| 4143 | const u32 *completed_at, |
| 4144 | const struct sha256 *payment_hash, |
| 4145 | u64 partid, |
| 4146 | u64 groupid, |
| 4147 | enum payment_status status, |
| 4148 | /* The destination may not be known if we used `sendonion` */ |
| 4149 | const struct node_id *destination, |
| 4150 | struct amount_msat msatoshi, |
| 4151 | struct amount_msat msatoshi_sent, |
| 4152 | struct amount_msat total_msat, |
| 4153 | /* If and only if PAYMENT_COMPLETE */ |
| 4154 | const struct preimage *payment_preimage, |
| 4155 | const struct secret *path_secrets, |
| 4156 | const struct node_id *route_nodes, |
| 4157 | const struct short_channel_id *route_channels, |
| 4158 | const char *invstring, |
| 4159 | const char *label, |
| 4160 | const char *description, |
| 4161 | const u8 *failonion, |
| 4162 | const struct sha256 *local_invreq_id) |
| 4163 | { |
| 4164 | struct wallet_payment *payment = tal(ctx, struct wallet_payment); |
| 4165 | |
| 4166 | payment->id = dbid; |
| 4167 | payment->updated_index = updated_index; |
| 4168 | payment->status = status; |
| 4169 | payment->timestamp = timestamp; |
| 4170 | payment->payment_hash = *payment_hash; |
| 4171 | payment->partid = partid; |
| 4172 | payment->groupid = groupid; |
| 4173 | payment->status = status; |
| 4174 | payment->msatoshi = msatoshi; |
| 4175 | payment->msatoshi_sent = msatoshi_sent; |
| 4176 | payment->total_msat = total_msat; |
| 4177 | |
| 4178 | /* Optional fields */ |
| 4179 | payment->completed_at = tal_dup_or_null(payment, u32, completed_at); |
| 4180 | payment->destination = tal_dup_or_null(payment, struct node_id, destination); |
| 4181 | payment->payment_preimage = tal_dup_or_null(payment, struct preimage, payment_preimage); |
| 4182 | payment->path_secrets = tal_dup_talarr(payment, struct secret, path_secrets); |
| 4183 | payment->route_nodes = tal_dup_talarr(payment, struct node_id, route_nodes); |
| 4184 | payment->route_channels = tal_dup_talarr(payment, struct short_channel_id, route_channels); |
| 4185 | payment->invstring = tal_strdup_or_null(payment, invstring); |
| 4186 | payment->label = tal_strdup_or_null(payment, label); |
| 4187 | payment->description = tal_strdup_or_null(payment, description); |
| 4188 | payment->failonion = tal_dup_talarr(payment, u8, failonion); |
| 4189 | payment->local_invreq_id = tal_dup_or_null(payment, struct sha256, local_invreq_id); |
| 4190 | |
| 4191 | return payment; |
| 4192 | } |
| 4193 | |
| 4194 | struct wallet_payment *payment_get_details(const tal_t *ctx, |
| 4195 | struct db_stmt *stmt) |
no test coverage detected