wallet/wallet.c
bool wallet_add_utxo(struct wallet *w, struct utxo *utxo,
		     enum wallet_output_type type)
{
	sqlite3_stmt *stmt;

	stmt = db_prepare(w->db, "INSERT INTO outputs (prev_out_tx, prev_out_index, value, type, status, keyindex, channel_id, peer_id, commitment_point) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);");
	sqlite3_bind_blob(stmt, 1, &utxo->txid, sizeof(utxo->txid), SQLITE_TRANSIENT);
	sqlite3_bind_int(stmt, 2, utxo->outnum);
	sqlite3_bind_int64(stmt, 3, utxo->amount);
	sqlite3_bind_int(stmt, 4, type);
	sqlite3_bind_int(stmt, 5, output_state_available);
	sqlite3_bind_int(stmt, 6, utxo->keyindex);
	if (utxo->close_info) {
		sqlite3_bind_int64(stmt, 7, utxo->close_info->channel_id);
		sqlite3_bind_pubkey(stmt, 8, &utxo->close_info->peer_id);
		sqlite3_bind_pubkey(stmt, 9, &utxo->close_info->commitment_point);
	} else {
		sqlite3_bind_null(stmt, 7);
		sqlite3_bind_null(stmt, 8);
		sqlite3_bind_null(stmt, 9);
	}
	return db_exec_prepared_mayfail(w->db, stmt);
}
/* We actually use the db constraints to uniquify, so OK if this fails. */
We actually use the db constraints to uniquify, so OK if this fails.
We actually use the db constraints to uniquify so OK if this fails .
bool wallet_add_utxo(struct wallet *w, struct utxo *utxo,
		     enum wallet_output_type type)
{
	sqlite3_stmt *stmt;
	stmt = db_prepare(w->db, "INSERT INTO outputs (prev_out_tx, prev_out_index, value, type, status, keyindex, channel_id, peer_id, commitment_point) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);");
	sqlite3_bind_blob(stmt, 1, &utxo->txid, sizeof(utxo->txid), SQLITE_TRANSIENT);
	sqlite3_bind_int(stmt, 2, utxo->outnum);
	sqlite3_bind_int64(stmt, 3, utxo->amount);
	sqlite3_bind_int(stmt, 4, type);
	sqlite3_bind_int(stmt, 5, output_state_available);
	sqlite3_bind_int(stmt, 6, utxo->keyindex);
	if (utxo->close_info) {
		sqlite3_bind_int64(stmt, 7, utxo->close_info->channel_id);
		sqlite3_bind_pubkey(stmt, 8, &utxo->close_info->peer_id);
		sqlite3_bind_pubkey(stmt, 9, &utxo->close_info->commitment_point);
	} else {
		sqlite3_bind_null(stmt, 7);
		sqlite3_bind_null(stmt, 8);
		sqlite3_bind_null(stmt, 9);
	}
	return db_exec_prepared_mayfail(w->db, stmt);
}
bool wallet_add_utxo ( struct wallet * w , struct utxo * utxo , enum wallet_output_type type ) { sqlite3_stmt * stmt ; stmt = db_prepare ( w -> db , " " ) ; sqlite3_bind_blob ( stmt , 1 , & utxo -> txid , sizeof ( utxo -> txid ) , SQLITE_TRANSIENT ) ; sqlite3_bind_int ( stmt , 2 , utxo -> outnum ) ; sqlite3_bind_int64 ( stmt , 3 , utxo -> amount ) ; sqlite3_bind_int ( stmt , 4 , type ) ; sqlite3_bind_int ( stmt , 5 , output_state_available ) ; sqlite3_bind_int ( stmt , 6 , utxo -> keyindex ) ; if ( utxo -> close_info ) { sqlite3_bind_int64 ( stmt , 7 , utxo -> close_info -> channel_id ) ; sqlite3_bind_pubkey ( stmt , 8 , & utxo -> close_info -> peer_id ) ; sqlite3_bind_pubkey ( stmt , 9 , & utxo -> close_info -> commitment_point ) ; } else { sqlite3_bind_null ( stmt , 7 ) ; sqlite3_bind_null ( stmt , 8 ) ; sqlite3_bind_null ( stmt , 9 ) ; } return db_exec_prepared_mayfail ( w -> db , stmt ) ; }
We actually use the db constraints to uniquify, so OK if this fails.
We actually use the db constraints to uniquify so OK if this fails .