multi: loop in swap

This commit is contained in:
Joost Jager 2019-03-12 16:10:37 +01:00
parent 6a0a9556a0
commit 3e960b8b54
No known key found for this signature in database
GPG key ID: A61B9D4C393C59C7
28 changed files with 2376 additions and 273 deletions

View file

@ -19,6 +19,7 @@ var (
testTime = time.Date(2018, time.January, 9, 14, 00, 00, 0, time.UTC)
testLoopOutOnChainCltvDelta = int32(30)
testChargeOnChainCltvDelta = int32(100)
testCltvDelta = 50
testSwapFeeBase = btcutil.Amount(21)
testSwapFeeRate = int64(100)
@ -123,3 +124,40 @@ func getInvoice(hash lntypes.Hash, amt btcutil.Amount, memo string) (string, err
return reqString, nil
}
func (s *serverMock) NewLoopInSwap(ctx context.Context,
swapHash lntypes.Hash, amount btcutil.Amount,
senderKey [33]byte, swapInvoice string) (
*newLoopInResponse, error) {
_, receiverKey := test.CreateKey(101)
if amount != s.expectedSwapAmt {
return nil, errors.New("unexpected test swap amount")
}
var receiverKeyArray [33]byte
copy(receiverKeyArray[:], receiverKey.SerializeCompressed())
s.swapInvoice = swapInvoice
s.swapHash = swapHash
resp := &newLoopInResponse{
expiry: s.height + testChargeOnChainCltvDelta,
receiverKey: receiverKeyArray,
}
return resp, nil
}
func (s *serverMock) GetLoopInTerms(ctx context.Context) (
*LoopInTerms, error) {
return &LoopInTerms{
SwapFeeBase: testSwapFeeBase,
SwapFeeRate: testSwapFeeRate,
CltvDelta: testChargeOnChainCltvDelta,
MinSwapAmount: testMinSwapAmount,
MaxSwapAmount: testMaxSwapAmount,
}, nil
}