use np2wsh for loop in htlc

This commit is contained in:
Joost Jager 2019-04-04 12:20:45 +02:00
parent e765baa1f9
commit 30c7d71c57
No known key found for this signature in database
GPG key ID: A61B9D4C393C59C7
10 changed files with 219 additions and 113 deletions

16
swap.go
View file

@ -29,29 +29,26 @@ type swapKit struct {
}
func newSwapKit(hash lntypes.Hash, swapType Type, cfg *swapConfig,
contract *loopdb.SwapContract) (*swapKit, error) {
contract *loopdb.SwapContract, outputType swap.HtlcOutputType) (
*swapKit, error) {
// Compose expected on-chain swap script
htlc, err := swap.NewHtlc(
contract.CltvExpiry, contract.SenderKey,
contract.ReceiverKey, hash,
contract.ReceiverKey, hash, outputType,
cfg.lnd.ChainParams,
)
if err != nil {
return nil, err
}
// Log htlc address for debugging.
htlcAddress, err := htlc.Address(cfg.lnd.ChainParams)
if err != nil {
return nil, err
}
log := &SwapLog{
Hash: hash,
Logger: logger,
}
log.Infof("Htlc address: %v", htlcAddress)
// Log htlc address for debugging.
log.Infof("Htlc address: %v", htlc.Address)
return &swapKit{
swapConfig: *cfg,
@ -72,6 +69,7 @@ func (s *swapKit) sendUpdate(ctx context.Context) error {
SwapType: s.swapType,
LastUpdate: s.lastUpdateTime,
State: s.state,
HtlcAddress: s.htlc.Address,
}
s.log.Infof("state %v", info.State)