mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-15 12:50:29 +02:00
client/order: add new PendingChanKey function
The mapping in this function ensures that a given bid/ask pair will have a unique deterministic pending channel ID to use when registering funding shims and also making channels.
This commit is contained in:
parent
9f9e7d7cb6
commit
61ea03e4ee
1 changed files with 16 additions and 0 deletions
|
|
@ -426,3 +426,19 @@ type ServerOrderParams struct {
|
|||
// trader's account key.
|
||||
RawSig []byte
|
||||
}
|
||||
|
||||
// PendingChanKey calculates the pending channel ID to be used for funding
|
||||
// purposes for a given bid and ask. The pending channel ID must be unique, so
|
||||
// we use the hash of the concatenation of the two nonces: sha256(askNonce ||
|
||||
// bidNonce).
|
||||
func PendingChanKey(askNonce, bidNonce Nonce) [32]byte {
|
||||
var pid [32]byte
|
||||
|
||||
h := sha256.New()
|
||||
_, _ = h.Write(askNonce[:])
|
||||
_, _ = h.Write(bidNonce[:])
|
||||
|
||||
copy(pid[:], h.Sum(nil))
|
||||
|
||||
return pid
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue