multi: update sub-systems to use latest iteration of wire messages
This commit is contained in:
parent
ccbbcf389b
commit
12f69692aa
@ -332,7 +332,7 @@ func (f *fundingManager) handleFundingRequest(fmsg *fundingRequestMsg) {
|
|||||||
// number and send ErrorGeneric to remote peer if condition is violated.
|
// number and send ErrorGeneric to remote peer if condition is violated.
|
||||||
if len(f.activeReservations[fmsg.peer.id]) >= cfg.MaxPendingChannels {
|
if len(f.activeReservations[fmsg.peer.id]) >= cfg.MaxPendingChannels {
|
||||||
errMsg := &lnwire.ErrorGeneric{
|
errMsg := &lnwire.ErrorGeneric{
|
||||||
ChannelPoint: &wire.OutPoint{
|
ChannelPoint: wire.OutPoint{
|
||||||
Hash: chainhash.Hash{},
|
Hash: chainhash.Hash{},
|
||||||
Index: 0,
|
Index: 0,
|
||||||
},
|
},
|
||||||
@ -354,7 +354,7 @@ func (f *fundingManager) handleFundingRequest(fmsg *fundingRequestMsg) {
|
|||||||
}
|
}
|
||||||
if !isSynced {
|
if !isSynced {
|
||||||
errMsg := &lnwire.ErrorGeneric{
|
errMsg := &lnwire.ErrorGeneric{
|
||||||
ChannelPoint: &wire.OutPoint{
|
ChannelPoint: wire.OutPoint{
|
||||||
Hash: chainhash.Hash{},
|
Hash: chainhash.Hash{},
|
||||||
Index: 0,
|
Index: 0,
|
||||||
},
|
},
|
||||||
@ -479,7 +479,8 @@ func (f *fundingManager) handleFundingResponse(fmsg *fundingResponseMsg) {
|
|||||||
// contribution. At this point, we can process their contribution which
|
// contribution. At this point, we can process their contribution which
|
||||||
// allows us to construct and sign both the commitment transaction, and
|
// allows us to construct and sign both the commitment transaction, and
|
||||||
// the funding transaction.
|
// the funding transaction.
|
||||||
_, addrs, _, err := txscript.ExtractPkScriptAddrs(msg.DeliveryPkScript, activeNetParams.Params)
|
_, addrs, _, err := txscript.ExtractPkScriptAddrs(msg.DeliveryPkScript,
|
||||||
|
activeNetParams.Params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fndgLog.Errorf("Unable to extract addresses from script: %v", err)
|
fndgLog.Errorf("Unable to extract addresses from script: %v", err)
|
||||||
resCtx.err <- err
|
resCtx.err <- err
|
||||||
@ -523,7 +524,7 @@ func (f *fundingManager) handleFundingResponse(fmsg *fundingResponseMsg) {
|
|||||||
revocationKey := resCtx.reservation.OurContribution().RevocationKey
|
revocationKey := resCtx.reservation.OurContribution().RevocationKey
|
||||||
obsfucator := resCtx.reservation.StateNumObfuscator()
|
obsfucator := resCtx.reservation.StateNumObfuscator()
|
||||||
|
|
||||||
fundingComplete := lnwire.NewSingleFundingComplete(chanID, outPoint,
|
fundingComplete := lnwire.NewSingleFundingComplete(chanID, *outPoint,
|
||||||
commitSig, revocationKey, obsfucator)
|
commitSig, revocationKey, obsfucator)
|
||||||
sourcePeer.queueMsg(fundingComplete, nil)
|
sourcePeer.queueMsg(fundingComplete, nil)
|
||||||
}
|
}
|
||||||
@ -564,7 +565,7 @@ func (f *fundingManager) handleFundingComplete(fmsg *fundingCompleteMsg) {
|
|||||||
// With all the necessary data available, attempt to advance the
|
// With all the necessary data available, attempt to advance the
|
||||||
// funding workflow to the next stage. If this succeeds then the
|
// funding workflow to the next stage. If this succeeds then the
|
||||||
// funding transaction will broadcast after our next message.
|
// funding transaction will broadcast after our next message.
|
||||||
err = resCtx.reservation.CompleteReservationSingle(revokeKey, fundingOut,
|
err = resCtx.reservation.CompleteReservationSingle(revokeKey, &fundingOut,
|
||||||
commitSig, obsfucator)
|
commitSig, obsfucator)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO(roasbeef): better error logging: peerID, channelID, etc.
|
// TODO(roasbeef): better error logging: peerID, channelID, etc.
|
||||||
@ -586,7 +587,7 @@ func (f *fundingManager) handleFundingComplete(fmsg *fundingCompleteMsg) {
|
|||||||
|
|
||||||
// Register a new barrier for this channel to properly synchronize with
|
// Register a new barrier for this channel to properly synchronize with
|
||||||
// the peer's readHandler once the channel is open.
|
// the peer's readHandler once the channel is open.
|
||||||
fmsg.peer.barrierInits <- *fundingOut
|
fmsg.peer.barrierInits <- fundingOut
|
||||||
|
|
||||||
fndgLog.Infof("sending signComplete for pendingID(%v) over ChannelPoint(%v)",
|
fndgLog.Infof("sending signComplete for pendingID(%v) over ChannelPoint(%v)",
|
||||||
fmsg.msg.ChannelID, fundingOut)
|
fmsg.msg.ChannelID, fundingOut)
|
||||||
|
@ -247,7 +247,7 @@ out:
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
wireMsg := htlcPkt.msg.(*lnwire.HTLCAddRequest)
|
wireMsg := htlcPkt.msg.(*lnwire.UpdateAddHTLC)
|
||||||
amt := btcutil.Amount(wireMsg.Amount)
|
amt := btcutil.Amount(wireMsg.Amount)
|
||||||
|
|
||||||
// Handle this send request in a distinct goroutine in
|
// Handle this send request in a distinct goroutine in
|
||||||
@ -289,10 +289,10 @@ out:
|
|||||||
switch wireMsg := pkt.msg.(type) {
|
switch wireMsg := pkt.msg.(type) {
|
||||||
// A link has just forwarded us a new HTLC, therefore
|
// A link has just forwarded us a new HTLC, therefore
|
||||||
// we initiate the payment circuit within our internal
|
// we initiate the payment circuit within our internal
|
||||||
// state so we can properly forward the ultimate
|
// state so we can properly forward the ultimate settle
|
||||||
// settle message.
|
// message.
|
||||||
case *lnwire.HTLCAddRequest:
|
case *lnwire.UpdateAddHTLC:
|
||||||
payHash := wireMsg.RedemptionHashes[0]
|
payHash := wireMsg.PaymentHash
|
||||||
|
|
||||||
// Create the two ends of the payment circuit
|
// Create the two ends of the payment circuit
|
||||||
// required to ensure completion of this new
|
// required to ensure completion of this new
|
||||||
@ -314,8 +314,8 @@ out:
|
|||||||
// origin.
|
// origin.
|
||||||
cancelPkt := &htlcPacket{
|
cancelPkt := &htlcPacket{
|
||||||
payHash: payHash,
|
payHash: payHash,
|
||||||
msg: &lnwire.CancelHTLC{
|
msg: &lnwire.UpdateFailHTLC{
|
||||||
Reason: lnwire.UnknownDestination,
|
Reason: []byte{uint8(lnwire.UnknownDestination)},
|
||||||
},
|
},
|
||||||
err: make(chan error, 1),
|
err: make(chan error, 1),
|
||||||
}
|
}
|
||||||
@ -346,8 +346,8 @@ out:
|
|||||||
|
|
||||||
pkt := &htlcPacket{
|
pkt := &htlcPacket{
|
||||||
payHash: payHash,
|
payHash: payHash,
|
||||||
msg: &lnwire.CancelHTLC{
|
msg: &lnwire.UpdateFailHTLC{
|
||||||
Reason: lnwire.InsufficientCapacity,
|
Reason: []byte{uint8(lnwire.InsufficientCapacity)},
|
||||||
},
|
},
|
||||||
err: make(chan error, 1),
|
err: make(chan error, 1),
|
||||||
}
|
}
|
||||||
@ -361,7 +361,7 @@ out:
|
|||||||
settle: settleLink,
|
settle: settleLink,
|
||||||
}
|
}
|
||||||
|
|
||||||
cKey := circuitKey(wireMsg.RedemptionHashes[0])
|
cKey := circuitKey(wireMsg.PaymentHash)
|
||||||
h.paymentCircuits[cKey] = circuit
|
h.paymentCircuits[cKey] = circuit
|
||||||
|
|
||||||
hswcLog.Debugf("Creating onion circuit for %x: %v<->%v",
|
hswcLog.Debugf("Creating onion circuit for %x: %v<->%v",
|
||||||
@ -391,8 +391,8 @@ out:
|
|||||||
// can finalize the payment circuit by forwarding the
|
// can finalize the payment circuit by forwarding the
|
||||||
// settle msg to the link which initially created the
|
// settle msg to the link which initially created the
|
||||||
// circuit.
|
// circuit.
|
||||||
case *lnwire.HTLCSettleRequest:
|
case *lnwire.UpdateFufillHTLC:
|
||||||
rHash := fastsha256.Sum256(wireMsg.RedemptionProofs[0][:])
|
rHash := fastsha256.Sum256(wireMsg.PaymentPreimage[:])
|
||||||
var cKey circuitKey
|
var cKey circuitKey
|
||||||
copy(cKey[:], rHash[:])
|
copy(cKey[:], rHash[:])
|
||||||
|
|
||||||
@ -434,7 +434,7 @@ out:
|
|||||||
// by an upstream peer somewhere within the ultimate
|
// by an upstream peer somewhere within the ultimate
|
||||||
// route. In response, we'll terminate the payment
|
// route. In response, we'll terminate the payment
|
||||||
// circuit and propagate the error backwards.
|
// circuit and propagate the error backwards.
|
||||||
case *lnwire.CancelHTLC:
|
case *lnwire.UpdateFailHTLC:
|
||||||
// In order to properly handle the error, we'll
|
// In order to properly handle the error, we'll
|
||||||
// need to look up the original circuit that
|
// need to look up the original circuit that
|
||||||
// the incoming HTLC created.
|
// the incoming HTLC created.
|
||||||
|
@ -82,7 +82,7 @@ type Config struct {
|
|||||||
// denoted by its public key. A non-nil error is to be returned if the
|
// denoted by its public key. A non-nil error is to be returned if the
|
||||||
// payment was unsuccessful.
|
// payment was unsuccessful.
|
||||||
SendToSwitch func(firstHop *btcec.PublicKey,
|
SendToSwitch func(firstHop *btcec.PublicKey,
|
||||||
htlcAdd *lnwire.HTLCAddRequest) error
|
htlcAdd *lnwire.UpdateAddHTLC) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelRouter is the layer 3 router within the Lightning stack. Below the
|
// ChannelRouter is the layer 3 router within the Lightning stack. Below the
|
||||||
@ -1126,11 +1126,11 @@ func (r *ChannelRouter) SendPayment(payment *LightningPayment) (*Route, error) {
|
|||||||
// Craft an HTLC packet to send to the layer 2 switch. The metadata
|
// Craft an HTLC packet to send to the layer 2 switch. The metadata
|
||||||
// within this packet will be used to route the payment through the
|
// within this packet will be used to route the payment through the
|
||||||
// network, starting with the first-hop.
|
// network, starting with the first-hop.
|
||||||
htlcAdd := &lnwire.HTLCAddRequest{
|
htlcAdd := &lnwire.UpdateAddHTLC{
|
||||||
Amount: route.TotalAmount,
|
Amount: route.TotalAmount,
|
||||||
RedemptionHashes: [][32]byte{payment.PaymentHash},
|
PaymentHash: payment.PaymentHash,
|
||||||
OnionBlob: sphinxPacket,
|
|
||||||
}
|
}
|
||||||
|
copy(htlcAdd.OnionBlob[:], sphinxPacket)
|
||||||
|
|
||||||
// Attempt to send this payment through the network to complete the
|
// Attempt to send this payment through the network to complete the
|
||||||
// payment. If this attempt fails, then we'll bail our early.
|
// payment. If this attempt fails, then we'll bail our early.
|
||||||
|
@ -179,7 +179,7 @@ func newServer(listenAddrs []string, notifier chainntnfs.ChainNotifier,
|
|||||||
Broadcast: s.broadcastMessage,
|
Broadcast: s.broadcastMessage,
|
||||||
SendMessages: s.sendToPeer,
|
SendMessages: s.sendToPeer,
|
||||||
SendToSwitch: func(firstHop *btcec.PublicKey,
|
SendToSwitch: func(firstHop *btcec.PublicKey,
|
||||||
htlcAdd *lnwire.HTLCAddRequest) error {
|
htlcAdd *lnwire.UpdateAddHTLC) error {
|
||||||
|
|
||||||
firstHopPub := firstHop.SerializeCompressed()
|
firstHopPub := firstHop.SerializeCompressed()
|
||||||
destInterface := chainhash.Hash(fastsha256.Sum256(firstHopPub))
|
destInterface := chainhash.Hash(fastsha256.Sum256(firstHopPub))
|
||||||
|
Loading…
Reference in New Issue
Block a user