Commit 12cc234a authored by Sergei Zubov's avatar Sergei Zubov

Add SyncFromDate to API

parent e6c10051
......@@ -1026,6 +1026,25 @@ namespace Stratis.Bitcoin.Features.Wallet.Controllers
this.walletSyncManager.SyncFromHeight(block.Height);
return this.Ok();
}
/// <summary>
/// Request the node to sync back from a given date.
/// </summary>
/// <param name="request">The model containing the date from which to start syncing.</param>
/// <returns></returns>
[HttpPost]
[Route("syncfromdate")]
public IActionResult SyncFromDate([FromBody] WalletSyncFromDateRequest request)
{
if (!this.ModelState.IsValid)
{
return ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, "Invalid date format", string.Empty);
}
this.walletSyncManager.SyncFromDate(request.Date);
return this.Ok();
}
/// <summary>
/// Builds an <see cref="IActionResult"/> containing errors contained in the <see cref="ControllerBase.ModelState"/>.
......
......@@ -260,4 +260,13 @@ namespace Stratis.Bitcoin.Features.Wallet.Models
[Required]
public string Password { get; set; }
}
/// <summary>
/// Object used to synchronize a wallet
/// </summary>
public class WalletSyncFromDateRequest : RequestModel
{
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTime Date { get; set; }
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment