multi: update sub-systems to use latest iteration of wire messages

This commit is contained in:
Olaoluwa Osuntokun 2017-02-16 20:41:16 +08:00
parent ccbbcf389b
commit 12f69692aa
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
4 changed files with 26 additions and 25 deletions

@ -332,7 +332,7 @@ func (f *fundingManager) handleFundingRequest(fmsg *fundingRequestMsg) {
// number and send ErrorGeneric to remote peer if condition is violated.
if len(f.activeReservations[fmsg.peer.id]) >= cfg.MaxPendingChannels {
errMsg := &lnwire.ErrorGeneric{
ChannelPoint: &wire.OutPoint{
ChannelPoint: wire.OutPoint{
Hash: chainhash.Hash{},
Index: 0,
},
@ -354,7 +354,7 @@ func (f *fundingManager) handleFundingRequest(fmsg *fundingRequestMsg) {
}
if !isSynced {
errMsg := &lnwire.ErrorGeneric{
ChannelPoint: &wire.OutPoint{
ChannelPoint: wire.OutPoint{
Hash: chainhash.Hash{},
Index: 0,
},
@ -479,7 +479,8 @@ func (f *fundingManager) handleFundingResponse(fmsg *fundingResponseMsg) {
// contribution. At this point, we can process their contribution which
// allows us to construct and sign both the commitment transaction, and
// the funding transaction.
_, addrs, _, err := txscript.ExtractPkScriptAddrs(msg.DeliveryPkScript, activeNetParams.Params)
_, addrs, _, err := txscript.ExtractPkScriptAddrs(msg.DeliveryPkScript,
activeNetParams.Params)
if err != nil {
fndgLog.Errorf("Unable to extract addresses from script: %v", err)
resCtx.err <- err
@ -523,7 +524,7 @@ func (f *fundingManager) handleFundingResponse(fmsg *fundingResponseMsg) {
revocationKey := resCtx.reservation.OurContribution().RevocationKey
obsfucator := resCtx.reservation.StateNumObfuscator()
fundingComplete := lnwire.NewSingleFundingComplete(chanID, outPoint,
fundingComplete := lnwire.NewSingleFundingComplete(chanID, *outPoint,
commitSig, revocationKey, obsfucator)
sourcePeer.queueMsg(fundingComplete, nil)
}
@ -564,7 +565,7 @@ func (f *fundingManager) handleFundingComplete(fmsg *fundingCompleteMsg) {
// With all the necessary data available, attempt to advance the
// funding workflow to the next stage. If this succeeds then the
// funding transaction will broadcast after our next message.
err = resCtx.reservation.CompleteReservationSingle(revokeKey, fundingOut,
err = resCtx.reservation.CompleteReservationSingle(revokeKey, &fundingOut,
commitSig, obsfucator)
if err != nil {
// 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
// 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)",
fmsg.msg.ChannelID, fundingOut)

@ -247,7 +247,7 @@ out:
continue
}
wireMsg := htlcPkt.msg.(*lnwire.HTLCAddRequest)
wireMsg := htlcPkt.msg.(*lnwire.UpdateAddHTLC)
amt := btcutil.Amount(wireMsg.Amount)
// Handle this send request in a distinct goroutine in
@ -289,10 +289,10 @@ out:
switch wireMsg := pkt.msg.(type) {
// A link has just forwarded us a new HTLC, therefore
// we initiate the payment circuit within our internal
// state so we can properly forward the ultimate
// settle message.
case *lnwire.HTLCAddRequest:
payHash := wireMsg.RedemptionHashes[0]
// state so we can properly forward the ultimate settle
// message.
case *lnwire.UpdateAddHTLC:
payHash := wireMsg.PaymentHash
// Create the two ends of the payment circuit
// required to ensure completion of this new
@ -314,8 +314,8 @@ out:
// origin.
cancelPkt := &htlcPacket{
payHash: payHash,
msg: &lnwire.CancelHTLC{
Reason: lnwire.UnknownDestination,
msg: &lnwire.UpdateFailHTLC{
Reason: []byte{uint8(lnwire.UnknownDestination)},
},
err: make(chan error, 1),
}
@ -346,8 +346,8 @@ out:
pkt := &htlcPacket{
payHash: payHash,
msg: &lnwire.CancelHTLC{
Reason: lnwire.InsufficientCapacity,
msg: &lnwire.UpdateFailHTLC{
Reason: []byte{uint8(lnwire.InsufficientCapacity)},
},
err: make(chan error, 1),
}
@ -361,7 +361,7 @@ out:
settle: settleLink,
}
cKey := circuitKey(wireMsg.RedemptionHashes[0])
cKey := circuitKey(wireMsg.PaymentHash)
h.paymentCircuits[cKey] = circuit
hswcLog.Debugf("Creating onion circuit for %x: %v<->%v",
@ -391,8 +391,8 @@ out:
// can finalize the payment circuit by forwarding the
// settle msg to the link which initially created the
// circuit.
case *lnwire.HTLCSettleRequest:
rHash := fastsha256.Sum256(wireMsg.RedemptionProofs[0][:])
case *lnwire.UpdateFufillHTLC:
rHash := fastsha256.Sum256(wireMsg.PaymentPreimage[:])
var cKey circuitKey
copy(cKey[:], rHash[:])
@ -434,7 +434,7 @@ out:
// by an upstream peer somewhere within the ultimate
// route. In response, we'll terminate the payment
// circuit and propagate the error backwards.
case *lnwire.CancelHTLC:
case *lnwire.UpdateFailHTLC:
// In order to properly handle the error, we'll
// need to look up the original circuit that
// 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
// payment was unsuccessful.
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
@ -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
// within this packet will be used to route the payment through the
// network, starting with the first-hop.
htlcAdd := &lnwire.HTLCAddRequest{
Amount: route.TotalAmount,
RedemptionHashes: [][32]byte{payment.PaymentHash},
OnionBlob: sphinxPacket,
htlcAdd := &lnwire.UpdateAddHTLC{
Amount: route.TotalAmount,
PaymentHash: payment.PaymentHash,
}
copy(htlcAdd.OnionBlob[:], sphinxPacket)
// Attempt to send this payment through the network to complete the
// 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,
SendMessages: s.sendToPeer,
SendToSwitch: func(firstHop *btcec.PublicKey,
htlcAdd *lnwire.HTLCAddRequest) error {
htlcAdd *lnwire.UpdateAddHTLC) error {
firstHopPub := firstHop.SerializeCompressed()
destInterface := chainhash.Hash(fastsha256.Sum256(firstHopPub))