Open altafan opened 1 year ago
Or, instead, should it send the serialzied json object within the response message
Yep lets keep it stateless, and return the JSON object in a string or something
Some considerations to revamp the discussion:
backup.json
file into the datadir.Improvements to the original proposal:
ExportBackup
and exposed by the Operator servicewallet
section should include msRootPath
in case a ms ocean wallet is behind the scenes (v1 daemon)account
section should include xpubs
, no need to export the master blinding key since it can be always derived from mnemonic (ss wallet account) or xpubs (ms wallet account)market
should include base and quote asset precisions, fees
should be replaced by percentage and fixed fees, both with values specified on base and quote assets as per v1 spec. "trades": [
{
"id": "...",
"type": "...",
"marketName": "...",
"marketBaseAsset": "...",
"marketQuoteAsset": "...",
"marketPrice": {
"basePrice": "...",
"quotePrice": "..."
},
"marketPercentageFee": {
"baseAsset": <value>,
"quoteAsset": <value>
},
"marketFixedFee": {
"baseAsset": <value>,
"quoteAsset": <value>
},
"feeAsset": "...",
"feeAmount": <value>,
"status": {
"code": <value>,
"failed": <value>
},
"psetBase64": "...",
"txid": "...",
"txHex": "...",
"expiryTime": <value>,
"settlementTime": <value>,
"swapRequest": {
"id": "...",
"message": "..."
"timestamp": <value>
}, *Swap
"swapAccept": {
"id": "...",
"message": "..."
"timestamp": <value>
},
"swapComplete": {
"id": "...",
"message": "..."
"timestamp": <value>
},
"swapFail": {
"id": "...",
"message": "..."
"timestamp": <value>
}
},
...
],
"deposits": [
{
"txid": "...",
"accountName": "...",
"totAmountPerAsset": {
"<asset>": <value>,
...
},
"timestamp": <value>
},
...
],
"withdrawals": [
{
"txid": "...",
"accountName": "...",
"totAmountPerAsset": {
"<asset>": <value>,
...
},
"timestamp": <value>
},
...
]
Translation from old to new format:
hash(baseAsset + quoteAsset)
(amountR + fixedFeeAmount) : 100 - percentageFee = x : percentageFee
that allows us to find the percentage fee amount, the total fee amount should be calculated with the following formula: feeAmount := percentageFeeAmount + fixedFeeAmount = ((amountR + fixedFeeAmount) * percentageFee / 100 - percentageFee) + fixedFeeAmount
.All good, but my main issue with datadir is that we cannot build GUI tools to perform "export" & "import"
If we assume "i have my 0.x daemon on the same machine where I am upgrading" that should be handled with a migration routine in V1 that if recognize a datadir with old data, will perform migration automatically under the hood.
The JSON idea was more I have my daemon (either 0.x or 1.x) running and I want to spin-up an exact clone somewhere else in a different infrastructure. Maybe we should consider the bytes option instead of JSON? Ideally can be a server-stream to chunk multiple pieces together in order to be able to handle the scale of a huge file (with grpc-gateway will still be base64 strings I guess, but with chunking make it scalable)
So as wrap-up, let's split up the task in priorities:
At the moment, when recovering a wallet from a seed, the only thing restored is basically it's status, meant as accounts, addresses, txsa dn utxos. Thanks to some env vars and to the very specific structure of the daemon's embedded wallet we're able to restore its markets in term of just associating base and quote asset to a specific wallet account. We lose all those info like their fees, strategies etc.
In order to facilitate the restoration of all daemon's markets, we plan to add a new rpc
ExportBackupFile
that basically creates a JSON object with all relative information about the daemon's wallet and markets.The following JSON is an example of the content of such backup file and we should iterate over this, so feedbacks are more than welcome:
@tiero @sekulicd what do you think of this as a starting point?
I also have an open question:
What should be the behavior of this rpc? Should it create the JSON file somewhere like for example in the datadir? Or, instead, should it send the serialzied json object within the response message and let the client eventually create the file?