Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Breeze
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
Breeze
Commits
c2cde249
Commit
c2cde249
authored
May 14, 2017
by
Jeremy Bokobza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Returning 200 OK for Loading and recovering a wallet
parent
bc225cb7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
31 deletions
+25
-31
ApiSpecification.md
Breeze.Documentation/ApiSpecification.md
+16
-3
Breeze.Api.Tests.csproj
Breeze/src/Breeze.Api.Tests/Breeze.Api.Tests.csproj
+2
-2
ControllersTests.cs
Breeze/src/Breeze.Api.Tests/ControllersTests.cs
+4
-12
WalletController.cs
Breeze/src/Breeze.Wallet/Controllers/WalletController.cs
+3
-14
No files found.
Breeze.Documentation/ApiSpecification.md
View file @
c2cde249
...
...
@@ -147,10 +147,18 @@ POST /wallet/send-transaction - Attempts to send a transaction
## POST /wallet/load - Loads the wallet and starts syncing
### Parameters
```
{
"password": "password"
{
"password": "123456",
"folderPath": "Wallets", // optional, if the folder path is not the default one
"name": "myWallet"
}
```
### Response
```
200 (OK)
```
## POST /wallet/recover - Recovers the wallet
### Parameters
```
...
...
@@ -158,11 +166,16 @@ POST /wallet/send-transaction - Attempts to send a transaction
"network": "main", // "main" or "testnet"
"password": "password",
"mnemonic": "foo bar buz",
"creationTime": "2017-02-03" // DateTimeOffset.ParseExact("1998-01-01", "yyyy-MM-dd", CultureInfo.InvariantCulture), utc time
"name": "testwallet-recovered",
"folderPath": "Wallets", // optional, if the folder path is not the default one
"creationTime": "2017-02-25 16:20:33" // date from which to start looking for transactions
}
```
### Response
Cannot check if the password is good or not. If the password is wrong it'll recover a wallet with the wrong password.
```
200 (OK)
```
## DELETE /wallet - Deletes the wallet
Works as expected.
...
...
Breeze/src/Breeze.Api.Tests/Breeze.Api.Tests.csproj
View file @
c2cde249
...
...
@@ -16,12 +16,12 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170106-08" />
<PackageReference Include="NStratis" Version="3.0.2.
17
" />
<PackageReference Include="NStratis" Version="3.0.2.
23
" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta5-build1225" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.2.0-beta5-build3474" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.0" />
<PackageReference Include="Moq" Version="4.7.
8
" />
<PackageReference Include="Moq" Version="4.7.
10
" />
</ItemGroup>
</Project>
Breeze/src/Breeze.Api.Tests/ControllersTests.cs
View file @
c2cde249
...
...
@@ -66,12 +66,8 @@ namespace Breeze.Api.Tests
// Assert
mockWalletWrapper
.
VerifyAll
();
var
viewResult
=
Assert
.
IsType
<
JsonResult
>(
result
);
Assert
.
NotNull
(
viewResult
.
Value
);
Assert
.
IsType
<
WalletModel
>(
viewResult
.
Value
);
var
model
=
viewResult
.
Value
as
WalletModel
;
Assert
.
Equal
(
"Main"
,
model
.
Network
);
var
viewResult
=
Assert
.
IsType
<
OkResult
>(
result
);
Assert
.
Equal
(
200
,
viewResult
.
StatusCode
);
}
[
Fact
]
...
...
@@ -97,12 +93,8 @@ namespace Breeze.Api.Tests
// Assert
mockWalletWrapper
.
VerifyAll
();
var
viewResult
=
Assert
.
IsType
<
JsonResult
>(
result
);
Assert
.
NotNull
(
viewResult
.
Value
);
Assert
.
IsType
<
WalletModel
>(
viewResult
.
Value
);
var
model
=
viewResult
.
Value
as
WalletModel
;
Assert
.
Equal
(
"Main"
,
model
.
Network
);
var
viewResult
=
Assert
.
IsType
<
OkResult
>(
result
);
Assert
.
Equal
(
200
,
viewResult
.
StatusCode
);
}
[
Fact
]
...
...
Breeze/src/Breeze.Wallet/Controllers/WalletController.cs
View file @
c2cde249
...
...
@@ -78,14 +78,9 @@ namespace Breeze.Wallet.Controllers
{
// get the wallet folder
DirectoryInfo
walletFolder
=
GetWalletFolder
(
request
.
FolderPath
);
Wallet
wallet
=
this
.
walletManager
.
LoadWallet
(
request
.
Password
,
walletFolder
.
FullName
,
request
.
Name
);
return
this
.
Json
(
new
WalletModel
{
Network
=
wallet
.
Network
.
Name
,
// Addresses = wallet.GetFirstNAddresses(10).Select(a => a.ToWif()),
FileName
=
wallet
.
WalletFilePath
});
return
this
.
Ok
();
}
catch
(
FileNotFoundException
e
)
{
...
...
@@ -122,18 +117,12 @@ namespace Breeze.Wallet.Controllers
{
// get the wallet folder
DirectoryInfo
walletFolder
=
GetWalletFolder
(
request
.
FolderPath
);
Wallet
wallet
=
this
.
walletManager
.
RecoverWallet
(
request
.
Password
,
walletFolder
.
FullName
,
request
.
Name
,
request
.
Network
,
request
.
Mnemonic
,
null
,
request
.
CreationDate
);
// start syncing the wallet from the creation date
this
.
tracker
.
SyncFrom
(
request
.
CreationDate
);
return
this
.
Json
(
new
WalletModel
{
Network
=
wallet
.
Network
.
Name
,
// Addresses = wallet.GetFirstNAddresses(10).Select(a => a.ToWif()),
FileName
=
wallet
.
WalletFilePath
});
return
this
.
Ok
();
}
catch
(
InvalidOperationException
e
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment