-
Notifications
You must be signed in to change notification settings - Fork 102
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
dex/networks,server/eth: decode swap data message blob #1320
Conversation
cd2d8ab
to
360e6d7
Compare
Not quite ready, but rebased and slightly updated. live_test.go needs the lgpl build flag now. |
360e6d7
to
e7f2edc
Compare
// Contract is the contract script. | ||
// Contract is the unique swap contract data. This may be a redeem script | ||
// for UTXO assets, or other information that uniquely identifies the swap | ||
// for account-based assets e.g. a contract version and secret hash for ETH. | ||
Contract dex.Bytes | ||
// SecretHash is the contract's secret hash. |
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.
It's interesting that these two fields were already redundant. The SecretHash
field is basically a convenience, or possibly useful in a future asset if the Contract
bytes is distinct, but I don't see that happening. Either way, I'm not inclined to remove it.
// from redemption.Spends.Contract. Even for scriptable UTXO assets, the | ||
// redeem script in this Contract field is redundant with the SecretHash | ||
// field as ExtractSwapDetails can be applied to extract the hash. | ||
ver, secretHash, err := dexeth.DecodeContractData(redemption.Spends.Contract) |
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.
Note that AuditContract
is still in PR, but see also my comment: https://github.com/decred/dcrdex/pull/1319/files#r764101981
5dc6d61
to
8181c18
Compare
The msgjson.Init.Contract and server/asset.Contract.RedeemScript fields contain an encoding of the ETH contract version concatenated with the swap's secret hash that is the unique key for the swap. This updates server/asset/eth's ValidateContract and Contract methods to decode and check this data. This also adds the dexeth.EncodeSwapData and DecodeSwapData functions. Arrayify swapReceipt.secretHash.
8181c18
to
01d24bf
Compare
The
msgjson.Init.Contract
andserver/asset.Contract.RedeemScript
fieldscontain an encoding of the ETH contract version concatenated with the
swap's secret hash that is the unique key for the swap.
This updates server/asset/eth's
ValidateContract
andContract
methodsto decode and check this data.
This also adds the
dexeth.EncodeContractData
andDecodeContractData
functions.