| 890 | } |
| 891 | |
| 892 | bool wallet_remote_ann_sigs_load(const tal_t *ctx, struct wallet *w, u64 id, |
| 893 | secp256k1_ecdsa_signature **remote_ann_node_sig, |
| 894 | secp256k1_ecdsa_signature **remote_ann_bitcoin_sig) |
| 895 | { |
| 896 | struct db_stmt *stmt; |
| 897 | bool res; |
| 898 | stmt = db_prepare_v2( |
| 899 | w->db, SQL("SELECT remote_ann_node_sig, remote_ann_bitcoin_sig" |
| 900 | " FROM channels WHERE id = ?")); |
| 901 | db_bind_u64(stmt, 0, id); |
| 902 | db_query_prepared(stmt); |
| 903 | |
| 904 | res = db_step(stmt); |
| 905 | |
| 906 | /* This must succeed, since we know the channel exists */ |
| 907 | assert(res); |
| 908 | |
| 909 | /* if only one sig exists, forget the sig and hope peer send new ones*/ |
| 910 | if (db_col_is_null(stmt, "remote_ann_node_sig") |
| 911 | || db_col_is_null(stmt, "remote_ann_bitcoin_sig")) { |
| 912 | db_col_ignore(stmt, "remote_ann_bitcoin_sig"); |
| 913 | *remote_ann_node_sig = *remote_ann_bitcoin_sig = NULL; |
| 914 | tal_free(stmt); |
| 915 | return true; |
| 916 | } |
| 917 | |
| 918 | /* the case left over is both sigs exist */ |
| 919 | *remote_ann_node_sig = tal(ctx, secp256k1_ecdsa_signature); |
| 920 | *remote_ann_bitcoin_sig = tal(ctx, secp256k1_ecdsa_signature); |
| 921 | |
| 922 | if (!db_col_signature(stmt, "remote_ann_node_sig", *remote_ann_node_sig)) |
| 923 | goto fail; |
| 924 | |
| 925 | if (!db_col_signature(stmt, "remote_ann_bitcoin_sig", *remote_ann_bitcoin_sig)) |
| 926 | goto fail; |
| 927 | |
| 928 | tal_free(stmt); |
| 929 | return true; |
| 930 | |
| 931 | fail: |
| 932 | *remote_ann_node_sig = tal_free(*remote_ann_node_sig); |
| 933 | *remote_ann_bitcoin_sig = tal_free(*remote_ann_bitcoin_sig); |
| 934 | tal_free(stmt); |
| 935 | return false; |
| 936 | } |
| 937 | |
| 938 | static struct fee_states *wallet_channel_fee_states_load(struct wallet *w, |
| 939 | const u64 id, |