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

Function wallet_stmt2output

wallet/wallet.c:193–246  ·  view source on GitHub ↗

* wallet_stmt2output - Extract data from stmt and fill an UTXO */

Source from the content-addressed store, hash-verified

191 * wallet_stmt2output - Extract data from stmt and fill an UTXO
192 */
193static struct utxo *wallet_stmt2output(const tal_t *ctx, struct db_stmt *stmt)
194{
195 struct utxo *utxo = tal(ctx, struct utxo);
196 u32 *blockheight, *spendheight;
197 db_col_txid(stmt, "prev_out_tx", &utxo->outpoint.txid);
198 utxo->outpoint.n = db_col_int(stmt, "prev_out_index");
199 db_col_amount_sat(stmt, "value", &utxo->amount);
200 utxo->is_p2sh = db_col_int(stmt, "type") == p2sh_wpkh;
201 utxo->status = db_col_int(stmt, "status");
202 utxo->keyindex = db_col_int(stmt, "keyindex");
203 if (!db_col_is_null(stmt, "channel_id")) {
204 utxo->close_info = tal(utxo, struct unilateral_close_info);
205 utxo->close_info->channel_id = db_col_u64(stmt, "channel_id");
206 db_col_node_id(stmt, "peer_id", &utxo->close_info->peer_id);
207 if (!db_col_is_null(stmt, "commitment_point")) {
208 utxo->close_info->commitment_point
209 = tal(utxo->close_info, struct pubkey);
210 db_col_pubkey(stmt, "commitment_point",
211 utxo->close_info->commitment_point);
212 } else
213 utxo->close_info->commitment_point = NULL;
214 utxo->close_info->option_anchor_outputs
215 = db_col_int(stmt, "option_anchor_outputs");
216 utxo->close_info->csv = db_col_int(stmt, "csv_lock");
217 } else {
218 utxo->close_info = NULL;
219 db_col_ignore(stmt, "peer_id");
220 db_col_ignore(stmt, "commitment_point");
221 db_col_ignore(stmt, "option_anchor_outputs");
222 db_col_ignore(stmt, "csv_lock");
223 }
224
225 utxo->scriptPubkey = db_col_arr(utxo, stmt, "scriptpubkey", u8);
226
227 utxo->blockheight = NULL;
228 utxo->spendheight = NULL;
229
230 if (!db_col_is_null(stmt, "confirmation_height")) {
231 blockheight = tal(utxo, u32);
232 *blockheight = db_col_int(stmt, "confirmation_height");
233 utxo->blockheight = blockheight;
234 }
235
236 if (!db_col_is_null(stmt, "spend_height")) {
237 spendheight = tal(utxo, u32);
238 *spendheight = db_col_int(stmt, "spend_height");
239 utxo->spendheight = spendheight;
240 }
241
242 /* This column can be null if 0.9.1 db or below. */
243 utxo->reserved_til = db_col_int_or_default(stmt, "reserved_til", 0);
244
245 return utxo;
246}
247
248bool wallet_update_output_status(struct wallet *w,
249 const struct bitcoin_outpoint *outpoint,

Callers 4

wallet_get_utxosFunction · 0.85
wallet_utxo_getFunction · 0.85
wallet_find_utxoFunction · 0.85

Calls 9

db_col_txidFunction · 0.85
db_col_intFunction · 0.85
db_col_amount_satFunction · 0.85
db_col_is_nullFunction · 0.85
db_col_u64Function · 0.85
db_col_node_idFunction · 0.85
db_col_pubkeyFunction · 0.85
db_col_ignoreFunction · 0.85
db_col_int_or_defaultFunction · 0.85

Tested by

no test coverage detected