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
server/eth: Implement ValidateContract. #1273
Conversation
server/asset/eth/coiner.go
Outdated
|
||
// Auth ensures that a user really has the keys to spend a funding coin by | ||
// verifying a message signed by the funding coin address. | ||
func (c *amountCoin) Auth(pubkeys, sigs [][]byte, msg []byte) error { |
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.
I guess we'll still have to figure out when and how we confirm ownership of the account, but it won't be via coin like this anymore.
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.
Yeah, this pr is only the last commit, so I'll rebase and remove that.
server/asset/eth/eth.go
Outdated
// contains valid counterparty, secret hash, and locktime. | ||
func (eth *Backend) ValidateContract(txdata []byte) error { | ||
_, _, _, err := dexeth.ParseInitiateData(txdata) | ||
if err != nil { | ||
return fmt.Errorf("unable to parse contract txdata: %w", err) | ||
} | ||
return nil | ||
} |
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.
Require the the Contract field of msgjson.Init be filled with the txdata used to create the swap. Validate that txdata to be of the correct format sending the expected types of arguments.
ce5fdf7
to
fb7bf35
Compare
Why did you choose the contract to be the txdata? Now that we are doing batch initiations, the contract will represent multiple swaps. |
I'd like to get on the same page here, so to provide context for discussion:
func (dcr *Backend) ValidateContract(contract []byte) error {
_, _, _, _, err := dexdcr.ExtractSwapDetails(contract, chainParams)
return err
}
|
So, please bring me up to speed: what is the current coinID encoding and contract bytes in the |
@chappjc see also #1154 (comment) I recommend that for With that scheme, the only thing |
In that comment, @buck54321:
What do you mean by "earlier than this"? Init is the start of the swap, so the contract address that's targeted for the swap would need to come here. Do you intend to pick it out of the transaction data after retrieving it via the txid? If so, this would come in processInit from the Will have a look at #1307
I agree that ValidateContract can and should do very little at this stage (before finding the tx on-chain). |
We shouldn't even place an order on a server using an unsupported contract address. #1301 links the contract address to the |
Yes, of course. But this is server-side validation. In some server checks (not Presumably the |
Right. And the contract address doesn't need be decoded from the txdata. It should be the to address of the transaction. |
Great, we are 100% on the same page now. The contract address is validated when |
@@ -59,6 +59,9 @@ const ( | |||
// which holds the ETH, an amount of ETH in gwei, and a random nonce to | |||
// avoid duplicate coin IDs. | |||
CIDAmount | |||
// SecretHashSize is the byte-length of the hash of the secret key used | |||
// in swaps. | |||
SecretHashSize = 32 |
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.
Will be moved to dex/networks
Whoops.
Also whoops, but I guess we don't have that data yet anyway. |
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.
Looks good.
work towards #1154 depends on #1235