| 27 | } |
| 28 | |
| 29 | struct uncommitted_channel * |
| 30 | new_uncommitted_channel(struct peer *peer) |
| 31 | { |
| 32 | struct lightningd *ld = peer->ld; |
| 33 | struct uncommitted_channel *uc = tal(ld, struct uncommitted_channel); |
| 34 | const u8 *new_channel_msg; |
| 35 | |
| 36 | uc->peer = peer; |
| 37 | assert(!peer->uncommitted_channel); |
| 38 | |
| 39 | uc->transient_billboard = NULL; |
| 40 | uc->dbid = wallet_get_channel_dbid(ld->wallet); |
| 41 | |
| 42 | uc->log = new_logger(uc, ld->log_book, &uc->peer->id, |
| 43 | "chan#%"PRIu64, uc->dbid); |
| 44 | |
| 45 | uc->fc = NULL; |
| 46 | uc->our_config.id = 0; |
| 47 | /* BOLT #2: |
| 48 | * |
| 49 | * The sender: |
| 50 | * - if `channel_type` includes `option_zeroconf`: |
| 51 | * - MUST set `minimum_depth` to zero. |
| 52 | * - otherwise: |
| 53 | * - SHOULD set `minimum_depth` to a number of blocks it |
| 54 | * considers reasonable to avoid double-spending of the |
| 55 | * funding transaction. |
| 56 | */ |
| 57 | /* We override this in openchannel hook if we want zeroconf */ |
| 58 | uc->minimum_depth = ld->config.funding_confirms; |
| 59 | |
| 60 | /* Use default 1% reserve if not otherwise specified. If this |
| 61 | * is not-NULL it will be used by openingd as absolute value |
| 62 | * (clamped to dust limit). */ |
| 63 | uc->reserve = NULL; |
| 64 | |
| 65 | memset(&uc->cid, 0xFF, sizeof(uc->cid)); |
| 66 | |
| 67 | /* Declare the new channel to the HSM. */ |
| 68 | new_channel_msg = towire_hsmd_new_channel(NULL, &uc->peer->id, uc->dbid); |
| 69 | new_channel_msg = hsm_sync_req(tmpctx, ld, take(new_channel_msg)); |
| 70 | if (!fromwire_hsmd_new_channel_reply(new_channel_msg)) |
| 71 | fatal("HSM gave bad hsm_new_channel_reply %s", |
| 72 | tal_hex(new_channel_msg, new_channel_msg)); |
| 73 | |
| 74 | get_channel_basepoints(ld, &uc->peer->id, uc->dbid, |
| 75 | &uc->local_basepoints, &uc->local_funding_pubkey); |
| 76 | |
| 77 | uc->peer->uncommitted_channel = uc; |
| 78 | tal_add_destructor(uc, destroy_uncommitted_channel); |
| 79 | |
| 80 | uc->got_offer = false; |
| 81 | uc->open_daemon = NULL; |
| 82 | |
| 83 | return uc; |
| 84 | } |
| 85 | |
| 86 | void opend_channel_errmsg(struct uncommitted_channel *uc, |
no test coverage detected