diff --git a/cmd/loop/loopin.go b/cmd/loop/loopin.go index e724f98..bf990ca 100644 --- a/cmd/loop/loopin.go +++ b/cmd/loop/loopin.go @@ -68,7 +68,7 @@ func loopIn(ctx *cli.Context) error { } limits := getInLimits(amt, quote) - err = displayLimits(swap.TypeIn, amt, limits, external) + err = displayLimits(swap.TypeIn, amt, limits, external, "") if err != nil { return err } diff --git a/cmd/loop/loopout.go b/cmd/loop/loopout.go index 3b0cd90..64d80c3 100644 --- a/cmd/loop/loopout.go +++ b/cmd/loop/loopout.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + "time" "github.com/lightninglabs/loop" "github.com/lightninglabs/loop/looprpc" @@ -44,6 +45,16 @@ var loopOutCommand = cli.Command{ "should be swept within", Value: uint64(loop.DefaultSweepConfTarget), }, + cli.BoolFlag{ + Name: "fast", + Usage: "Indicate you want to swap immediately, " + + "paying potentially a higher fee. If not " + + "set the swap server might choose to wait up " + + "to 30 minutes before publishing the swap " + + "HTLC on-chain, to save on chain fees. Not " + + "setting this flag might result in a lower " + + "swap fee.", + }, }, Action: loopOut, } @@ -92,9 +103,19 @@ func loopOut(ctx *cli.Context) error { return err } - limits := getLimits(amt, quote) + // Show a warning if a slow swap was requested. + fast := ctx.Bool("fast") + warning := "" + if fast { + warning = "Fast swap requested." + } else { + warning = fmt.Sprintf("Regular swap speed requested, it "+ + "might take up to %v for the swap to be executed.", + defaultSwapWaitTime) + } - err = displayLimits(swap.TypeOut, amt, limits, false) + limits := getLimits(amt, quote) + err = displayLimits(swap.TypeOut, amt, limits, false, warning) if err != nil { return err } @@ -104,16 +125,24 @@ func loopOut(ctx *cli.Context) error { unchargeChannel = ctx.Uint64("channel") } + // Set our maximum swap wait time. If a fast swap is requested we set + // it to now, otherwise to 30 minutes in the future. + swapDeadline := time.Now() + if !fast { + swapDeadline = time.Now().Add(defaultSwapWaitTime) + } + resp, err := client.LoopOut(context.Background(), &looprpc.LoopOutRequest{ - Amt: int64(amt), - Dest: destAddr, - MaxMinerFee: int64(limits.maxMinerFee), - MaxPrepayAmt: int64(*limits.maxPrepayAmt), - MaxSwapFee: int64(limits.maxSwapFee), - MaxPrepayRoutingFee: int64(*limits.maxPrepayRoutingFee), - MaxSwapRoutingFee: int64(*limits.maxSwapRoutingFee), - LoopOutChannel: unchargeChannel, - SweepConfTarget: sweepConfTarget, + Amt: int64(amt), + Dest: destAddr, + MaxMinerFee: int64(limits.maxMinerFee), + MaxPrepayAmt: int64(*limits.maxPrepayAmt), + MaxSwapFee: int64(limits.maxSwapFee), + MaxPrepayRoutingFee: int64(*limits.maxPrepayRoutingFee), + MaxSwapRoutingFee: int64(*limits.maxSwapRoutingFee), + LoopOutChannel: unchargeChannel, + SweepConfTarget: sweepConfTarget, + SwapPublicationDeadline: uint64(swapDeadline.Unix()), }) if err != nil { return err diff --git a/cmd/loop/main.go b/cmd/loop/main.go index 3ef569a..17f3fed 100644 --- a/cmd/loop/main.go +++ b/cmd/loop/main.go @@ -26,6 +26,8 @@ var ( maxRoutingFeeBase = btcutil.Amount(10) maxRoutingFeeRate = int64(20000) + + defaultSwapWaitTime = 30 * time.Minute ) func printRespJSON(resp proto.Message) { @@ -117,7 +119,7 @@ func getLimits(amt btcutil.Amount, quote *looprpc.QuoteResponse) *limits { } func displayLimits(swapType swap.Type, amt btcutil.Amount, l *limits, - externalHtlc bool) error { + externalHtlc bool, warning string) error { totalSuccessMax := l.maxMinerFee + l.maxSwapFee if l.maxSwapRoutingFee != nil { @@ -138,6 +140,10 @@ func displayLimits(swapType swap.Type, amt btcutil.Amount, l *limits, amt, swapType, totalSuccessMax, ) + if warning != "" { + fmt.Println(warning) + } + fmt.Printf("CONTINUE SWAP? (y/n), expand fee detail (x): ") var answer string diff --git a/cmd/loopd/swapclient_server.go b/cmd/loopd/swapclient_server.go index b75ccea..ac295d2 100644 --- a/cmd/loopd/swapclient_server.go +++ b/cmd/loopd/swapclient_server.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "sort" + "time" "github.com/lightningnetwork/lnd/queue" @@ -76,6 +77,9 @@ func (s *swapClientServer) LoopOut(ctx context.Context, MaxSwapRoutingFee: btcutil.Amount(in.MaxSwapRoutingFee), MaxSwapFee: btcutil.Amount(in.MaxSwapFee), SweepConfTarget: sweepConfTarget, + SwapPublicationDeadline: time.Unix( + int64(in.SwapPublicationDeadline), 0, + ), } if in.LoopOutChannel != 0 { req.LoopOutChannel = &in.LoopOutChannel diff --git a/interface.go b/interface.go index 919c6ac..94d709b 100644 --- a/interface.go +++ b/interface.go @@ -64,8 +64,12 @@ type OutRequest struct { SweepConfTarget int32 // LoopOutChannel optionally specifies the short channel id of the - // channel to uncharge. + // channel to loop out. LoopOutChannel *uint64 + + // SwapPublicationDeadline can be set by the client to allow the server + // delaying publication of the swap HTLC to save on chain fees. + SwapPublicationDeadline time.Time } // Out contains the full details of a loop out request. This includes things @@ -149,7 +153,7 @@ type LoopInRequest struct { // MaxSwapFee is the maximum we are willing to pay the server for the // swap. This value is not disclosed in the swap initiation call, but if // the server asks for a higher fee, we abort the swap. Typically this - // value is taken from the response of the UnchargeQuote call. It + // value is taken from the response of the LoopInQuote call. It // includes the prepay amount. MaxSwapFee btcutil.Amount @@ -157,7 +161,7 @@ type LoopInRequest struct { // spent. If we publish the on-chain htlc and the fee estimate turns out // higher than this value, we cancel the swap. // - // MaxMinerFee is typically taken from the response of the UnchargeQuote + // MaxMinerFee is typically taken from the response of the LoopInQuote // call. MaxMinerFee btcutil.Amount @@ -166,7 +170,7 @@ type LoopInRequest struct { HtlcConfTarget int32 // LoopInChannel optionally specifies the short channel id of the - // channel to charge. + // channel to loop in. LoopInChannel *uint64 // ExternalHtlc specifies whether the htlc is published by an external @@ -174,7 +178,7 @@ type LoopInRequest struct { ExternalHtlc bool } -// LoopInTerms are the server terms on which it executes charge swaps. +// LoopInTerms are the server terms on which it executes loop in swaps. type LoopInTerms struct { // MinSwapAmount is the minimum amount that the server requires for a // swap. diff --git a/loopdb/loopout.go b/loopdb/loopout.go index 7dc173a..3df0654 100644 --- a/loopdb/loopout.go +++ b/loopdb/loopout.go @@ -45,6 +45,12 @@ type LoopOutContract struct { // MaxPrepayRoutingFee is the maximum off-chain fee in msat that may be // paid for the prepayment to the server. MaxPrepayRoutingFee btcutil.Amount + + // SwapPublicationDeadline is a timestamp that the server commits to + // have the on-chain swap published by. It is set by the client to + // allow the server to delay the publication in exchange for possibly + // lower fees. + SwapPublicationDeadline time.Time } // LoopOut is a combination of the contract and the updates. @@ -158,6 +164,13 @@ func deserializeLoopOutContract(value []byte, chainParams *chaincfg.Params) ( contract.UnchargeChannel = &unchargeChannel } + var deadlineNano int64 + err = binary.Read(r, byteOrder, &deadlineNano) + if err != nil { + return nil, err + } + contract.SwapPublicationDeadline = time.Unix(0, deadlineNano) + return &contract, nil } @@ -243,5 +256,10 @@ func serializeLoopOutContract(swap *LoopOutContract) ( return nil, err } + err = binary.Write(&b, byteOrder, swap.SwapPublicationDeadline.UnixNano()) + if err != nil { + return nil, err + } + return b.Bytes(), nil } diff --git a/loopdb/meta.go b/loopdb/meta.go index e1a3127..0d21f47 100644 --- a/loopdb/meta.go +++ b/loopdb/meta.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + "github.com/btcsuite/btcd/chaincfg" "github.com/coreos/bbolt" ) @@ -24,14 +25,17 @@ var ( // migration is a function which takes a prior outdated version of the database // instances and mutates the key/bucket structure to arrive at a more // up-to-date version of the database. -type migration func(tx *bbolt.Tx) error +type migration func(tx *bbolt.Tx, chainParams *chaincfg.Params) error var ( // dbVersions is storing all versions of database. If current version // of database don't match with latest version this list will be used // for retrieving all migration function that are need to apply to the // current db. - migrations = []migration{migrateCosts} + migrations = []migration{ + migrateCosts, + migrateSwapPublicationDeadline, + } latestDBVersion = uint32(len(migrations)) ) @@ -76,7 +80,7 @@ func setDBVersion(tx *bbolt.Tx, version uint32) error { // syncVersions function is used for safe db version synchronization. It // applies migration functions to the current database and recovers the // previous state of db if at least one error/panic appeared during migration. -func syncVersions(db *bbolt.DB) error { +func syncVersions(db *bbolt.DB, chainParams *chaincfg.Params) error { currentVersion, err := getDBVersion(db) if err != nil { return err @@ -112,7 +116,7 @@ func syncVersions(db *bbolt.DB) error { log.Infof("Applying migration #%v", v+1) migration := migrations[v] - if err := migration(tx); err != nil { + if err := migration(tx, chainParams); err != nil { log.Infof("Unable to apply migration #%v", v+1) return err diff --git a/loopdb/migration_01_costs.go b/loopdb/migration_01_costs.go index 55d1df5..b56053e 100644 --- a/loopdb/migration_01_costs.go +++ b/loopdb/migration_01_costs.go @@ -4,12 +4,13 @@ import ( "errors" "fmt" + "github.com/btcsuite/btcd/chaincfg" "github.com/coreos/bbolt" ) // noMigrationAvailable is the fall back migration in case there is no migration // implemented. -func migrateCosts(tx *bbolt.Tx) error { +func migrateCosts(tx *bbolt.Tx, _ *chaincfg.Params) error { if err := migrateCostsForBucket(tx, loopInBucketKey); err != nil { return err } diff --git a/loopdb/migration_02_swap_publication_deadline.go b/loopdb/migration_02_swap_publication_deadline.go new file mode 100644 index 0000000..b6879cd --- /dev/null +++ b/loopdb/migration_02_swap_publication_deadline.go @@ -0,0 +1,58 @@ +package loopdb + +import ( + "bytes" + "errors" + "fmt" + + "github.com/btcsuite/btcd/chaincfg" + "github.com/coreos/bbolt" +) + +// migrateSwapPublicationDeadline migrates the database to v02, by adding the +// SwapPublicationDeadline field to loop out contracts. +func migrateSwapPublicationDeadline(tx *bbolt.Tx, chainParams *chaincfg.Params) error { + rootBucket := tx.Bucket(loopOutBucketKey) + if rootBucket == nil { + return errors.New("bucket does not exist") + } + + return rootBucket.ForEach(func(swapHash, v []byte) error { + // Only go into things that we know are sub-bucket + // keys. + if v != nil { + return nil + } + + // From the root bucket, we'll grab the next swap + // bucket for this swap from its swaphash. + swapBucket := rootBucket.Bucket(swapHash) + if swapBucket == nil { + return fmt.Errorf("swap bucket %x not found", + swapHash) + } + + // With the main swap bucket obtained, we'll grab the + // raw swap contract bytes. + contractBytes := swapBucket.Get(contractKey) + if contractBytes == nil { + return errors.New("contract not found") + } + + // Write the current contract serialization into a buffer. + b := &bytes.Buffer{} + if _, err := b.Write(contractBytes); err != nil { + return err + } + + // We migrate to the new format by copying the first 8 bytes + // (the creation time) to the end (the swap deadline) + var swapDeadline [8]byte + copy(swapDeadline[:], contractBytes[:8]) + if _, err := b.Write(swapDeadline[:]); err != nil { + return err + } + + return swapBucket.Put(contractKey, b.Bytes()) + }) +} diff --git a/loopdb/store.go b/loopdb/store.go index 2a90ce8..e075495 100644 --- a/loopdb/store.go +++ b/loopdb/store.go @@ -135,7 +135,7 @@ func NewBoltSwapStore(dbPath string, chainParams *chaincfg.Params) ( // Finally, before we start, we'll sync the DB versions to pick up any // possible DB migrations. - err = syncVersions(bdb) + err = syncVersions(bdb, chainParams) if err != nil { return nil, err } diff --git a/loopdb/store_test.go b/loopdb/store_test.go index 64d9451..1d9ceaa 100644 --- a/loopdb/store_test.go +++ b/loopdb/store_test.go @@ -82,12 +82,13 @@ func TestLoopOutStore(t *testing.T) { // doesn't interfere with DeepEqual. InitiationTime: time.Unix(0, initiationTime.UnixNano()), }, - MaxPrepayRoutingFee: 40, - PrepayInvoice: "prepayinvoice", - DestAddr: destAddr, - SwapInvoice: "swapinvoice", - MaxSwapRoutingFee: 30, - SweepConfTarget: 2, + MaxPrepayRoutingFee: 40, + PrepayInvoice: "prepayinvoice", + DestAddr: destAddr, + SwapInvoice: "swapinvoice", + MaxSwapRoutingFee: 30, + SweepConfTarget: 2, + SwapPublicationDeadline: time.Unix(0, initiationTime.UnixNano()), } // checkSwap is a test helper function that'll assert the state of a diff --git a/loopout.go b/loopout.go index 635f6d1..82b0f92 100644 --- a/loopout.go +++ b/loopout.go @@ -79,29 +79,36 @@ func newLoopOutSwap(globalCtx context.Context, cfg *swapConfig, // the server revocation key and the swap and prepay invoices. log.Infof("Initiating swap request at height %v", currentHeight) - swapResp, err := cfg.server.NewLoopOutSwap(globalCtx, swapHash, - request.Amount, receiverKey, + // The swap deadline will be given to the server for it to use as the + // latest swap publication time. + swapResp, err := cfg.server.NewLoopOutSwap( + globalCtx, swapHash, request.Amount, receiverKey, + request.SwapPublicationDeadline, ) if err != nil { return nil, fmt.Errorf("cannot initiate swap: %v", err) } - err = validateLoopOutContract(cfg.lnd, currentHeight, request, swapHash, swapResp) + err = validateLoopOutContract( + cfg.lnd, currentHeight, request, swapHash, swapResp, + ) if err != nil { return nil, err } - // Instantiate a struct that contains all required data to start the swap. + // Instantiate a struct that contains all required data to start the + // swap. initiationTime := time.Now() contract := loopdb.LoopOutContract{ - SwapInvoice: swapResp.swapInvoice, - DestAddr: request.DestAddr, - MaxSwapRoutingFee: request.MaxSwapRoutingFee, - SweepConfTarget: request.SweepConfTarget, - UnchargeChannel: request.LoopOutChannel, - PrepayInvoice: swapResp.prepayInvoice, - MaxPrepayRoutingFee: request.MaxPrepayRoutingFee, + SwapInvoice: swapResp.swapInvoice, + DestAddr: request.DestAddr, + MaxSwapRoutingFee: request.MaxSwapRoutingFee, + SweepConfTarget: request.SweepConfTarget, + UnchargeChannel: request.LoopOutChannel, + PrepayInvoice: swapResp.prepayInvoice, + MaxPrepayRoutingFee: request.MaxPrepayRoutingFee, + SwapPublicationDeadline: request.SwapPublicationDeadline, SwapContract: loopdb.SwapContract{ InitiationHeight: currentHeight, InitiationTime: initiationTime, diff --git a/looprpc/client.pb.go b/looprpc/client.pb.go index 10ab2dc..e701a4a 100644 --- a/looprpc/client.pb.go +++ b/looprpc/client.pb.go @@ -158,10 +158,17 @@ type LoopOutRequest struct { //* //The number of blocks from the on-chain HTLC's confirmation height that it //should be swept within. - SweepConfTarget int32 `protobuf:"varint,9,opt,name=sweep_conf_target,json=sweepConfTarget,proto3" json:"sweep_conf_target,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + SweepConfTarget int32 `protobuf:"varint,9,opt,name=sweep_conf_target,json=sweepConfTarget,proto3" json:"sweep_conf_target,omitempty"` + //* + //The latest time (in unix seconds) we allow the server to wait before + //publishing the HTLC on chain. Setting this to a larger value will give the + //server the opportunity to batch multiple swaps together, and wait for + //low-fee periods before publishing the HTLC, potentially resulting in a + //lower total swap fee. + SwapPublicationDeadline uint64 `protobuf:"varint,10,opt,name=swap_publication_deadline,json=swapPublicationDeadline,proto3" json:"swap_publication_deadline,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *LoopOutRequest) Reset() { *m = LoopOutRequest{} } @@ -252,6 +259,13 @@ func (m *LoopOutRequest) GetSweepConfTarget() int32 { return 0 } +func (m *LoopOutRequest) GetSwapPublicationDeadline() uint64 { + if m != nil { + return m.SwapPublicationDeadline + } + return 0 +} + type LoopInRequest struct { //* //Requested swap amount in sat. This does not include the swap and miner @@ -804,74 +818,76 @@ func init() { func init() { proto.RegisterFile("client.proto", fileDescriptor_014de31d7ac8c57c) } var fileDescriptor_014de31d7ac8c57c = []byte{ - // 1061 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x4f, 0x73, 0xda, 0x46, - 0x1c, 0x8d, 0x40, 0x18, 0xf1, 0xb3, 0x90, 0xc5, 0x3a, 0x71, 0x08, 0x6d, 0x26, 0x94, 0x36, 0x29, - 0xe3, 0x83, 0x69, 0x9d, 0x53, 0x7b, 0xa3, 0x98, 0xc4, 0x78, 0x6c, 0xe3, 0x0a, 0x9c, 0x99, 0xf6, - 0xa2, 0x6e, 0x61, 0xb1, 0x35, 0x83, 0x76, 0x15, 0x69, 0xf1, 0x9f, 0xe9, 0xe4, 0xd2, 0xaf, 0xd0, - 0x4f, 0xd2, 0x99, 0x7e, 0x93, 0xde, 0x7b, 0xea, 0xf4, 0x73, 0x74, 0xf6, 0xb7, 0x42, 0x16, 0x26, - 0xbe, 0xe4, 0x66, 0x9e, 0xde, 0xbe, 0xdf, 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, 0x83, 0xd4, 0x57, 0xa4, 0xdf, 0x2b, 0x4e, 0xe7, 0x37, 0x1a, 0xca, 0x0f, 0xe4, 0x67, - 0x70, 0xde, 0x32, 0xa9, 0x37, 0xf7, 0x49, 0xdd, 0x3f, 0xc3, 0x12, 0xdb, 0xa4, 0x96, 0xdb, 0x67, - 0xda, 0xfc, 0x2f, 0x39, 0xed, 0x4f, 0x6a, 0xff, 0x05, 0x6a, 0x3f, 0x23, 0x4f, 0xf3, 0xda, 0xb9, - 0xee, 0x7f, 0xdd, 0xc0, 0x7f, 0x42, 0x5e, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x26, 0x06, 0x26, - 0x30, 0xbb, 0x08, 0x00, 0x00, + // 1096 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x4f, 0x73, 0xda, 0xc6, + 0x1b, 0x8e, 0x40, 0x18, 0xf1, 0x5a, 0xc8, 0x62, 0x9d, 0xd8, 0x98, 0xdf, 0x2f, 0x13, 0xaa, 0x36, + 0x29, 0xe3, 0x43, 0x68, 0x93, 0x53, 0x73, 0xa3, 0x40, 0x12, 0x3c, 0xb6, 0xa1, 0x02, 0x67, 0xa6, + 0xbd, 0xa8, 0x1b, 0x58, 0x6c, 0xcd, 0x48, 0x2b, 0x45, 0x5a, 0xfc, 0x67, 0x3a, 0xb9, 0xf4, 0x2b, + 0xf4, 0xd6, 0x6f, 0xd1, 0x99, 0x7e, 0x93, 0xde, 0x7b, 0xea, 0xf4, 0x73, 0x74, 0xf6, 0x5d, 0x81, + 0x85, 0x89, 0x2f, 0xb9, 0x99, 0x67, 0x9f, 0x7d, 0xde, 0x3f, 0xfb, 0xbc, 0xaf, 0x0c, 0xe6, 0x34, + 0xf0, 0x19, 0x17, 0xcf, 0xe3, 0x24, 0x12, 0x11, 0x29, 0x07, 0x51, 0x14, 0x27, 0xf1, 0xb4, 0xf1, + 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 0x6b, + 0x36, 0x76, 0x9a, 0x28, 0xdd, 0x20, 0xf5, 0x35, 0xe9, 0x0f, 0x92, 0xd3, 0xfe, 0x85, 0x86, 0xe2, + 0x23, 0xf9, 0x09, 0xac, 0x37, 0x4c, 0xa8, 0xce, 0x7d, 0x56, 0xf6, 0x07, 0x18, 0x62, 0x97, 0xd4, + 0x72, 0xfd, 0xcc, 0x92, 0xff, 0x39, 0xa7, 0xfd, 0x59, 0xe9, 0x3f, 0x41, 0xed, 0x03, 0xb2, 0x9f, + 0xd7, 0xce, 0x65, 0xff, 0x7e, 0x0b, 0xff, 0x81, 0x79, 0xf9, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xc2, 0x6b, 0xe2, 0x2f, 0xf7, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/looprpc/client.proto b/looprpc/client.proto index 01e46b0..e91bde1 100644 --- a/looprpc/client.proto +++ b/looprpc/client.proto @@ -146,6 +146,15 @@ message LoopOutRequest { should be swept within. */ int32 sweep_conf_target = 9; + + /** + The latest time (in unix seconds) we allow the server to wait before + publishing the HTLC on chain. Setting this to a larger value will give the + server the opportunity to batch multiple swaps together, and wait for + low-fee periods before publishing the HTLC, potentially resulting in a + lower total swap fee. + */ + uint64 swap_publication_deadline = 10; } message LoopInRequest { diff --git a/looprpc/client.swagger.json b/looprpc/client.swagger.json index 0f76ba8..c5a631d 100644 --- a/looprpc/client.swagger.json +++ b/looprpc/client.swagger.json @@ -265,6 +265,11 @@ "type": "integer", "format": "int32", "description": "*\nThe number of blocks from the on-chain HTLC's confirmation height that it\nshould be swept within." + }, + "swap_publication_deadline": { + "type": "string", + "format": "uint64", + "description": "*\nThe latest time (in unix seconds) we allow the server to wait before\npublishing the HTLC on chain. Setting this to a larger value will give the\nserver the opportunity to batch multiple swaps together, and wait for\nlow-fee periods before publishing the HTLC, potentially resulting in a\nlower total swap fee." } } }, diff --git a/looprpc/server.pb.go b/looprpc/server.pb.go index b084aaf..9d1260e 100644 --- a/looprpc/server.pb.go +++ b/looprpc/server.pb.go @@ -24,12 +24,14 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type ServerLoopOutRequest struct { - ReceiverKey []byte `protobuf:"bytes,1,opt,name=receiver_key,json=receiverKey,proto3" json:"receiver_key,omitempty"` - SwapHash []byte `protobuf:"bytes,2,opt,name=swap_hash,json=swapHash,proto3" json:"swap_hash,omitempty"` - Amt uint64 `protobuf:"varint,3,opt,name=amt,proto3" json:"amt,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + ReceiverKey []byte `protobuf:"bytes,1,opt,name=receiver_key,json=receiverKey,proto3" json:"receiver_key,omitempty"` + SwapHash []byte `protobuf:"bytes,2,opt,name=swap_hash,json=swapHash,proto3" json:"swap_hash,omitempty"` + Amt uint64 `protobuf:"varint,3,opt,name=amt,proto3" json:"amt,omitempty"` + /// The unix time in seconds we want the on-chain swap to be published by. + SwapPublicationDeadline int64 `protobuf:"varint,4,opt,name=swap_publication_deadline,json=swapPublicationDeadline,proto3" json:"swap_publication_deadline,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *ServerLoopOutRequest) Reset() { *m = ServerLoopOutRequest{} } @@ -78,6 +80,13 @@ func (m *ServerLoopOutRequest) GetAmt() uint64 { return 0 } +func (m *ServerLoopOutRequest) GetSwapPublicationDeadline() int64 { + if m != nil { + return m.SwapPublicationDeadline + } + return 0 +} + type ServerLoopOutResponse struct { SwapInvoice string `protobuf:"bytes,1,opt,name=swap_invoice,json=swapInvoice,proto3" json:"swap_invoice,omitempty"` PrepayInvoice string `protobuf:"bytes,2,opt,name=prepay_invoice,json=prepayInvoice,proto3" json:"prepay_invoice,omitempty"` @@ -671,48 +680,50 @@ func init() { func init() { proto.RegisterFile("server.proto", fileDescriptor_ad098daeda4239f7) } var fileDescriptor_ad098daeda4239f7 = []byte{ - // 641 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x6b, 0x4e, 0xdb, 0x4c, - 0x14, 0x95, 0xed, 0x10, 0xbe, 0x5c, 0x12, 0xf8, 0x98, 0x3e, 0x64, 0x02, 0xa9, 0xc0, 0x52, 0x11, - 0x42, 0x2d, 0x48, 0xed, 0x0a, 0xa8, 0x10, 0x2a, 0x2a, 0x2a, 0xc5, 0xf0, 0xdf, 0x9a, 0x26, 0xb7, - 0xc4, 0x6a, 0xec, 0x99, 0xda, 0x93, 0x40, 0x36, 0xd0, 0x35, 0xb4, 0x0b, 0xeb, 0x42, 0xba, 0x83, - 0x6a, 0x1e, 0x26, 0x7e, 0x42, 0x91, 0xfa, 0x8f, 0x39, 0xf7, 0x70, 0xef, 0xb9, 0x67, 0xce, 0x38, - 0xd0, 0x4d, 0x31, 0x99, 0x61, 0x72, 0xc0, 0x13, 0x26, 0x18, 0x59, 0x9e, 0x30, 0xc6, 0x13, 0x3e, - 0xec, 0x6f, 0x5d, 0x33, 0x76, 0x3d, 0xc1, 0x43, 0xca, 0xc3, 0x43, 0x1a, 0xc7, 0x4c, 0x50, 0x11, - 0xb2, 0x38, 0xd5, 0x34, 0x6f, 0x0c, 0x4f, 0x2f, 0xd5, 0xbf, 0x9d, 0x31, 0xc6, 0xcf, 0xa7, 0xc2, - 0xc7, 0x6f, 0x53, 0x4c, 0x05, 0xd9, 0x81, 0x6e, 0x82, 0x43, 0x0c, 0x67, 0x98, 0x04, 0x5f, 0x71, - 0xee, 0x5a, 0xdb, 0xd6, 0x5e, 0xd7, 0x5f, 0xc9, 0xb0, 0x0f, 0x38, 0x27, 0x9b, 0xd0, 0x49, 0x6f, - 0x28, 0x0f, 0xc6, 0x34, 0x1d, 0xbb, 0xb6, 0xaa, 0xff, 0x27, 0x81, 0xf7, 0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1e, 0x34, 0xbe, 0x85, 0xfe, 0xe6, 0x3d, 0x1c, - 0x72, 0x0e, 0xab, 0x1f, 0xf1, 0xc6, 0x40, 0x72, 0x10, 0x19, 0xd4, 0xd3, 0xb3, 0x6e, 0x2f, 0x9a, - 0xca, 0xe6, 0xae, 0x17, 0x0a, 0xf5, 0xb7, 0xaa, 0x41, 0x61, 0x3e, 0x4f, 0x4d, 0x0a, 0x75, 0x83, - 0x33, 0x58, 0xc9, 0x1b, 0xbc, 0x53, 0xc3, 0x2d, 0x5e, 0x4c, 0xbf, 0xdf, 0x4c, 0x21, 0x67, 0xd0, - 0x33, 0xfb, 0x9e, 0xaa, 0xeb, 0x20, 0x5b, 0xb5, 0xe4, 0xac, 0xd5, 0xa0, 0xa1, 0x6a, 0x96, 0xbd, - 0xca, 0xb4, 0x69, 0xa9, 0xf5, 0xda, 0x0a, 0xab, 0x7a, 0xf7, 0x51, 0x74, 0xd7, 0xcf, 0x6d, 0xf5, - 0x83, 0xf9, 0xf6, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf1, 0xf9, 0x2f, 0x6f, 0x67, 0x07, 0x00, - 0x00, + // 674 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xdd, 0x4e, 0xdb, 0x4c, + 0x10, 0x95, 0xed, 0x10, 0xbe, 0x0c, 0x09, 0x7c, 0x6c, 0xff, 0x4c, 0x20, 0x15, 0x58, 0x2a, 0x42, + 0xa8, 0x05, 0xa9, 0xbd, 0xeb, 0x1d, 0x15, 0x42, 0x45, 0x45, 0xa5, 0x18, 0xee, 0xad, 0x25, 0x99, + 0x82, 0xd5, 0x78, 0x77, 0x6b, 0x6f, 0x02, 0x79, 0x81, 0x3e, 0x43, 0x7b, 0xdf, 0x57, 0xea, 0x83, + 0xf4, 0x0d, 0xaa, 0xfd, 0x31, 0xb1, 0x9d, 0x84, 0x14, 0xa9, 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, 0x1d, 0xc9, 0xd5, 0xa4, 0x96, 0x41, 0x73, 0x5a, 0x07, 0x20, 0x43, 0xd6, 0xb3, 0xf3, 0x7a, + 0x7a, 0x9e, 0x86, 0x41, 0xd4, 0xb4, 0x4f, 0xa1, 0x8e, 0xb7, 0x22, 0x4e, 0x47, 0x5a, 0xeb, 0x42, + 0x68, 0x4f, 0xc1, 0x2b, 0x58, 0x2b, 0x29, 0x3b, 0x1b, 0x70, 0x89, 0xb9, 0x8b, 0xd6, 0x05, 0xe7, + 0xce, 0x85, 0xe0, 0x87, 0x0b, 0x64, 0x92, 0x4f, 0x76, 0x61, 0xd5, 0x98, 0x43, 0x47, 0x09, 0x32, + 0x19, 0xf5, 0x30, 0x93, 0x76, 0x96, 0x15, 0x6d, 0x8a, 0xc1, 0x0f, 0x55, 0xd3, 0x35, 0xd0, 0x36, + 0x47, 0x9f, 0xd1, 0x4c, 0xe2, 0x85, 0x8b, 0xea, 0x7c, 0x84, 0x48, 0xb6, 0xa1, 0x95, 0x97, 0xa2, + 0x94, 0x4a, 0xd4, 0x63, 0x78, 0xef, 0x5c, 0xdf, 0x31, 0x96, 0x1c, 0x21, 0x86, 0x54, 0xea, 0x59, + 0xad, 0x25, 0x4a, 0x5e, 0x4d, 0xcb, 0x6b, 0x18, 0xe4, 0x20, 0x91, 0x64, 0x17, 0x56, 0x92, 0x98, + 0x45, 0xba, 0x15, 0x4d, 0xf8, 0x80, 0x49, 0x7f, 0x41, 0x71, 0x74, 0xa3, 0x56, 0x12, 0xb3, 0xf3, + 0x1b, 0x2a, 0x0e, 0x74, 0x41, 0x73, 0xe9, 0x6d, 0x89, 0x5b, 0x2f, 0x70, 0xe9, 0x6d, 0x81, 0xdb, + 0x01, 0xe8, 0xf6, 0xe5, 0x30, 0xea, 0x61, 0x5f, 0x52, 0x7f, 0x51, 0xfb, 0xd8, 0x50, 0xc8, 0xa1, + 0x02, 0x82, 0xf5, 0x8a, 0x95, 0x17, 0x98, 0x26, 0x99, 0xb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0x39, + 0x81, 0x96, 0x9d, 0xf7, 0x58, 0xaf, 0x83, 0x6c, 0x4c, 0x25, 0xe7, 0xad, 0x3a, 0x33, 0xaa, 0x76, + 0xd8, 0x8b, 0x5c, 0x9b, 0x91, 0x3a, 0x5d, 0x5b, 0x69, 0xd4, 0xe0, 0x3e, 0x8a, 0xe9, 0x7a, 0x59, + 0xd7, 0xbf, 0xb6, 0x6f, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x91, 0x34, 0x08, 0x26, 0xa4, 0x07, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/looprpc/server.proto b/looprpc/server.proto index dd1ca10..6125167 100644 --- a/looprpc/server.proto +++ b/looprpc/server.proto @@ -24,6 +24,9 @@ message ServerLoopOutRequest { bytes swap_hash = 2; uint64 amt = 3; + + /// The unix time in seconds we want the on-chain swap to be published by. + int64 swap_publication_deadline = 4; } message ServerLoopOutResponse { diff --git a/server_mock_test.go b/server_mock_test.go index 9afc7c4..5629904 100644 --- a/server_mock_test.go +++ b/server_mock_test.go @@ -53,7 +53,7 @@ func newServerMock() *serverMock { func (s *serverMock) NewLoopOutSwap(ctx context.Context, swapHash lntypes.Hash, amount btcutil.Amount, - receiverKey [33]byte) ( + receiverKey [33]byte, _ time.Time) ( *newLoopOutResponse, error) { _, senderKey := test.CreateKey(100) diff --git a/swap_server_client.go b/swap_server_client.go index 527cc0d..fde9e4f 100644 --- a/swap_server_client.go +++ b/swap_server_client.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "errors" "fmt" + "time" "github.com/lightninglabs/loop/looprpc" "github.com/lightningnetwork/lnd/lntypes" @@ -31,7 +32,8 @@ type swapServerClient interface { NewLoopOutSwap(ctx context.Context, swapHash lntypes.Hash, amount btcutil.Amount, - receiverKey [33]byte) ( + receiverKey [33]byte, + swapPublicationDeadline time.Time) ( *newLoopOutResponse, error) NewLoopInSwap(ctx context.Context, @@ -153,15 +155,17 @@ func (s *grpcSwapServerClient) GetLoopInQuote(ctx context.Context, func (s *grpcSwapServerClient) NewLoopOutSwap(ctx context.Context, swapHash lntypes.Hash, amount btcutil.Amount, - receiverKey [33]byte) (*newLoopOutResponse, error) { + receiverKey [33]byte, swapPublicationDeadline time.Time) ( + *newLoopOutResponse, error) { rpcCtx, rpcCancel := context.WithTimeout(ctx, serverRPCTimeout) defer rpcCancel() swapResp, err := s.server.NewLoopOutSwap(rpcCtx, &looprpc.ServerLoopOutRequest{ - SwapHash: swapHash[:], - Amt: uint64(amount), - ReceiverKey: receiverKey[:], + SwapHash: swapHash[:], + Amt: uint64(amount), + ReceiverKey: receiverKey[:], + SwapPublicationDeadline: swapPublicationDeadline.Unix(), }, ) if err != nil {