mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-16 13:00:37 +02:00
loopd: loop in from external address
Allow user to specify that htlc will be published by an external source. In that case no internal htlc tx will be published. To facilitate sending to the htlc address, the swap initiation response is extended with that address.
This commit is contained in:
parent
8b2da64b0a
commit
2e48ead6d6
12 changed files with 190 additions and 98 deletions
|
|
@ -19,6 +19,10 @@ type LoopInContract struct {
|
|||
// LoopInChannel is the channel to charge. If zero, any channel may
|
||||
// be used.
|
||||
LoopInChannel *uint64
|
||||
|
||||
// ExternalHtlc specifies whether the htlc is published by an external
|
||||
// source.
|
||||
ExternalHtlc bool
|
||||
}
|
||||
|
||||
// LoopIn is a combination of the contract and the updates.
|
||||
|
|
@ -100,6 +104,10 @@ func serializeLoopInContract(swap *LoopInContract) (
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if err := binary.Write(&b, byteOrder, swap.ExternalHtlc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
|
|
@ -164,5 +172,9 @@ func deserializeLoopInContract(value []byte) (*LoopInContract, error) {
|
|||
contract.LoopInChannel = &loopInChannel
|
||||
}
|
||||
|
||||
if err := binary.Read(r, byteOrder, &contract.ExternalHtlc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &contract, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@ func TestLoopInStore(t *testing.T) {
|
|||
},
|
||||
HtlcConfTarget: 2,
|
||||
LoopInChannel: &loopInChannel,
|
||||
ExternalHtlc: true,
|
||||
}
|
||||
|
||||
// checkSwap is a test helper function that'll assert the state of a
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue