Skip to content

Commit 23859e6

Browse files
Copilotevd0kim
andauthored
Fix fundee AcceptChannel to echo ChannelTypeTlv when funder proposes channel type
Agent-Logs-Url: https://github.com/standardsats/valet/sessions/c18fed05-eef4-461c-8ad6-e02fa4bb0a4b Co-authored-by: evd0kim <15425710+evd0kim@users.noreply.github.com>
1 parent d31c285 commit 23859e6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

app/src/main/java/immortan/ChannelNormal.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,16 @@ abstract class ChannelNormal(bag: ChannelBag) extends Channel {
122122

123123
case (null, init: INPUT_INIT_FUNDEE, -1) =>
124124
val ChannelKeys(_, _, fundingKey, revocationKey, _, delayedPaymentKey, htlcKey) = init.localParams.keys
125-
val emptyUpfrontShutdown: TlvStream[AcceptChannelTlv] = TlvStream(ChannelTlv UpfrontShutdownScript ByteVector.empty)
125+
// Echo back the funder's channel type (BOLT 2: fundee MUST set channel_type to the same value
126+
// as in open_channel, so the funder's validateParamsFunder check doesn't reject our accept_channel).
127+
val acceptTlvRecords = Seq[AcceptChannelTlv](ChannelTlv.UpfrontShutdownScript(ByteVector.empty)) ++
128+
init.channelFeatures.channelType_opt.map(ChannelTlv.ChannelTypeTlv).toSeq
129+
val acceptTlvStream: TlvStream[AcceptChannelTlv] = TlvStream(acceptTlvRecords: _*)
126130

127131
val accept = AcceptChannel(init.theirOpen.temporaryChannelId, init.localParams.dustLimit, init.localParams.maxHtlcValueInFlightMsat, init.localParams.channelReserve,
128132
init.localParams.htlcMinimum, minimumDepth = LNParams.minDepthBlocks, init.localParams.toSelfDelay, init.localParams.maxAcceptedHtlcs, fundingPubkey = fundingKey.publicKey,
129133
revocationBasepoint = revocationKey.publicKey, paymentBasepoint = init.localParams.walletStaticPaymentBasepoint, delayedPaymentBasepoint = delayedPaymentKey.publicKey,
130-
htlcBasepoint = htlcKey.publicKey, init.localParams.keys.commitmentPoint(index = 0L), emptyUpfrontShutdown)
134+
htlcBasepoint = htlcKey.publicKey, init.localParams.keys.commitmentPoint(index = 0L), acceptTlvStream)
131135

132136
val data1 = DATA_WAIT_FOR_FUNDING_CREATED(init, RemoteParams(init.theirOpen.dustLimitSatoshis, init.theirOpen.maxHtlcValueInFlightMsat, init.theirOpen.channelReserveSatoshis,
133137
init.theirOpen.htlcMinimumMsat, init.theirOpen.toSelfDelay, init.theirOpen.maxAcceptedHtlcs, init.theirOpen.fundingPubkey, init.theirOpen.revocationBasepoint,

0 commit comments

Comments
 (0)