-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change: node-dlc post163 integration #136
base: master
Are you sure you want to change the base?
Conversation
|
3d2359b
to
57c9b94
Compare
57c9b94
to
f8bff38
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this great work @maxpolizzo
Looking forward to taking another look at this after node-dlc is finalized
|
||
// Assign unique temporaryContractId to finalize DLC offer | ||
const dlcOffer = tempDlcOffer; | ||
dlcOffer.temporaryContractId = sha256(tempDlcOffer.serialize()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first glance, I was concerned about what if a user created two offers back to back (if the first one failed for example) which would result in an identical temporaryContractId
. However, if they call createDlcOffer
again, it'll randomly generate new serial ids, which should result in a different temporaryContractId
This LGTM 👍
|
||
// The following line is commented out because specifying empty | ||
// negotiationFields causes dlcAccept serialization to fail | ||
// dlcAccept.negotiationFields = new SingleNegotiationFields(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense since negotiationFields
was made an optional field in the DlcAccept
in https://github.com/discreetlogcontracts/dlcspecs/pull/163/files#diff-e0f5b925f91a1c09c6daf26f9a7d28816cb9ff9f08863faca719b7ee0a1cc065R204
Looks good to remove 👍
A future iteration of this could include the option to provide negotiation fields, but this can be added later.
(a, b) => Number(a.endpoint) - Number(b.endpoint), | ||
// Deep copy payoutFunction.pieces into piecesSorted to prevent sorting the | ||
// original payoutFunction.pieces array with .sort() | ||
const piecesSorted = Object.assign([], payoutFunction.pieces); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍
Changes for compatibility with post-163 node-dlc dependencies (see node-dlc PR 187)
To do before merging to
master
:v0.21.5
is published to NPM (currently those are pointing to local node-dlc packages)