wallet: use db_exec_mayfail() for wallet_add_utxo.

This is the only case where we actually rely on the db to ensure we don't
do something twice: don't error out if it fails.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-11-01 11:40:48 +10:30 committed by Christian Decker
parent b148b89baf
commit bbe7a03300

View File

@ -24,6 +24,7 @@ struct wallet *wallet_new(const tal_t *ctx, struct log *log)
return wallet; return wallet;
} }
/* We actually use the db constraints to uniquify, so OK if this fails. */
bool wallet_add_utxo(struct wallet *w, struct utxo *utxo, bool wallet_add_utxo(struct wallet *w, struct utxo *utxo,
enum wallet_output_type type) enum wallet_output_type type)
{ {
@ -36,7 +37,7 @@ bool wallet_add_utxo(struct wallet *w, struct utxo *utxo,
sqlite3_bind_int(stmt, 4, type); sqlite3_bind_int(stmt, 4, type);
sqlite3_bind_int(stmt, 5, output_state_available); sqlite3_bind_int(stmt, 5, output_state_available);
sqlite3_bind_int(stmt, 6, utxo->keyindex); sqlite3_bind_int(stmt, 6, utxo->keyindex);
return db_exec_prepared(w->db, stmt); return db_exec_prepared_mayfail(w->db, stmt);
} }
/** /**