File tree Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -754,12 +754,8 @@ type SellOrder struct {
754754 // must agree to pay.
755755 PaymentMaxAmt lnwire.MilliSatoshi
756756
757- // Expiry is the unix timestamp at which the order expires.
758- //
759- // TODO(ffranr): This is the invoice expiry unix timestamp in seconds.
760- // We should make use of this field to ensure quotes are valid for the
761- // duration of the invoice.
762- Expiry uint64
757+ // Expiry is the time at which the order expires.
758+ Expiry time.Time
763759
764760 // Peer is the peer that the buy order is intended for. This field is
765761 // optional.
Original file line number Diff line number Diff line change @@ -481,9 +481,11 @@ func (n *Negotiator) HandleOutgoingSellOrder(order SellOrder) {
481481
482482 if n .cfg .PriceOracle != nil && order .AssetSpecifier .IsSome () {
483483 // Query the price oracle for an asking price.
484+ //
485+ // TODO(ffranr): Pass the SellOrder expiry to the
486+ // price oracle at this point.
484487 assetRate , err := n .queryAskFromPriceOracle (
485- order .AssetSpecifier ,
486- fn .None [uint64 ](),
488+ order .AssetSpecifier , fn .None [uint64 ](),
487489 fn .Some (order .PaymentMaxAmt ),
488490 fn .None [rfqmsg.AssetRate ](),
489491 )
@@ -494,7 +496,7 @@ func (n *Negotiator) HandleOutgoingSellOrder(order SellOrder) {
494496 return
495497 }
496498
497- assetRateHint = fn.Some [rfqmsg. AssetRate ]( * assetRate )
499+ assetRateHint = fn .MaybeSome ( assetRate )
498500 }
499501
500502 request , err := rfqmsg .NewSellRequest (
Original file line number Diff line number Diff line change 99 "errors"
1010 "fmt"
1111 "io"
12+ "math"
1213 "net/http"
1314 "strings"
1415 "sync"
@@ -6423,9 +6424,17 @@ func unmarshalAssetSellOrder(
64236424 err )
64246425 }
64256426
6427+ // Convert expiry unix timestamp in seconds to time.Time.
6428+ if req .Expiry > math .MaxInt64 {
6429+ return nil , fmt .Errorf ("expiry must be less than or equal to " +
6430+ "math.MaxInt64 (expiry=%d)" , req .Expiry )
6431+ }
6432+ expiry := time .Unix (int64 (req .Expiry ), 0 ).UTC ()
6433+
64266434 return & rfq.SellOrder {
64276435 AssetSpecifier : assetSpecifier ,
64286436 PaymentMaxAmt : lnwire .MilliSatoshi (req .PaymentMaxAmt ),
6437+ Expiry : expiry ,
64296438 Peer : peer ,
64306439 }, nil
64316440}
You can’t perform that action at this time.
0 commit comments