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
d3b95586
Commit
d3b95586
authored
Mar 28, 2017
by
Jeremy Bokobza
Committed by
GitHub
Mar 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Safe to Wallet (
#4
)
parent
5c919e29
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
149 additions
and
66 deletions
+149
-66
ControllersTests.cs
Breeze/src/Breeze.Api.Tests/ControllersTests.cs
+29
-29
Safe.postman_collection.json
...e.Api.Tests/Postman requests/Safe.postman_collection.json
+10
-10
WalletController.cs
Breeze/src/Breeze.Wallet/Controllers/WalletController.cs
+14
-14
WalletCreation.cs
Breeze/src/Breeze.Wallet/Models/WalletCreation.cs
+7
-7
WalletFeature.cs
Breeze/src/Breeze.Wallet/WalletFeature.cs
+2
-2
WalletModel.cs
Breeze/src/Breeze.Wallet/WalletModel.cs
+1
-1
IWalletWrapper.cs
Breeze/src/Breeze.Wallet/Wrappers/IWalletWrapper.cs
+3
-3
WalletWrapper.cs
Breeze/src/Breeze.Wallet/Wrappers/WalletWrapper.cs
+83
-0
No files found.
Breeze/src/Breeze.Api.Tests/ControllersTests.cs
View file @
d3b95586
...
...
@@ -13,15 +13,15 @@ namespace Breeze.Api.Tests
public
class
ControllersTests
{
[
Fact
]
public
void
Create
Safe
SuccessfullyReturnsMnemonic
()
public
void
Create
Wallet
SuccessfullyReturnsMnemonic
()
{
var
mock
SafeCreate
=
new
Mock
<
ISafe
Wrapper
>();
mock
SafeCreate
.
Setup
(
safe
=>
safe
.
Create
(
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>())).
Returns
(
"mnemonic"
);
var
mock
WalletCreate
=
new
Mock
<
IWallet
Wrapper
>();
mock
WalletCreate
.
Setup
(
wallet
=>
wallet
.
Create
(
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>())).
Returns
(
"mnemonic"
);
var
controller
=
new
SafeController
(
mockSafe
Create
.
Object
);
var
controller
=
new
WalletController
(
mockWallet
Create
.
Object
);
// Act
var
result
=
controller
.
Create
(
new
Safe
CreationModel
var
result
=
controller
.
Create
(
new
Wallet
CreationModel
{
Name
=
"myName"
,
FolderPath
=
""
,
...
...
@@ -30,29 +30,29 @@ namespace Breeze.Api.Tests
});
// Assert
mock
Safe
Create
.
VerifyAll
();
mock
Wallet
Create
.
VerifyAll
();
var
viewResult
=
Assert
.
IsType
<
JsonResult
>(
result
);
Assert
.
Equal
(
"mnemonic"
,
viewResult
.
Value
);
Assert
.
NotNull
(
result
);
}
[
Fact
]
public
void
Load
SafeSuccessfullyReturnsSafe
Model
()
public
void
Load
WalletSuccessfullyReturnsWallet
Model
()
{
SafeModel
safeModel
=
new
Safe
Model
WalletModel
walletModel
=
new
Wallet
Model
{
FileName
=
"myWallet"
,
Network
=
"MainNet"
,
Addresses
=
new
List
<
string
>
{
"address1"
,
"address2"
,
"address3"
,
"address4"
,
"address5"
}
};
var
mock
SafeWrapper
=
new
Mock
<
ISafe
Wrapper
>();
mock
SafeWrapper
.
Setup
(
safe
=>
safe
.
Recover
(
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>())).
Returns
(
safe
Model
);
var
mock
WalletWrapper
=
new
Mock
<
IWallet
Wrapper
>();
mock
WalletWrapper
.
Setup
(
wallet
=>
wallet
.
Recover
(
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>())).
Returns
(
wallet
Model
);
var
controller
=
new
SafeController
(
mockSafe
Wrapper
.
Object
);
var
controller
=
new
WalletController
(
mockWallet
Wrapper
.
Object
);
// Act
var
result
=
controller
.
Recover
(
new
Safe
RecoveryModel
var
result
=
controller
.
Recover
(
new
Wallet
RecoveryModel
{
Name
=
"myName"
,
FolderPath
=
""
,
...
...
@@ -62,32 +62,32 @@ namespace Breeze.Api.Tests
});
// Assert
mock
Safe
Wrapper
.
VerifyAll
();
mock
Wallet
Wrapper
.
VerifyAll
();
var
viewResult
=
Assert
.
IsType
<
JsonResult
>(
result
);
Assert
.
NotNull
(
viewResult
.
Value
);
Assert
.
IsType
<
Safe
Model
>(
viewResult
.
Value
);
Assert
.
IsType
<
Wallet
Model
>(
viewResult
.
Value
);
var
model
=
viewResult
.
Value
as
Safe
Model
;
var
model
=
viewResult
.
Value
as
Wallet
Model
;
Assert
.
Equal
(
"myWallet"
,
model
.
FileName
);
}
[
Fact
]
public
void
Recover
SafeSuccessfullyReturnsSafe
Model
()
public
void
Recover
WalletSuccessfullyReturnsWallet
Model
()
{
SafeModel
safeModel
=
new
Safe
Model
WalletModel
walletModel
=
new
Wallet
Model
{
FileName
=
"myWallet"
,
Network
=
"MainNet"
,
Addresses
=
new
List
<
string
>
{
"address1"
,
"address2"
,
"address3"
,
"address4"
,
"address5"
}
};
var
mock
SafeWrapper
=
new
Mock
<
ISafe
Wrapper
>();
mock
SafeWrapper
.
Setup
(
safe
=>
safe
.
Load
(
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>())).
Returns
(
safe
Model
);
var
mock
WalletWrapper
=
new
Mock
<
IWallet
Wrapper
>();
mock
WalletWrapper
.
Setup
(
wallet
=>
wallet
.
Load
(
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>())).
Returns
(
wallet
Model
);
var
controller
=
new
SafeController
(
mockSafe
Wrapper
.
Object
);
var
controller
=
new
WalletController
(
mockWallet
Wrapper
.
Object
);
// Act
var
result
=
controller
.
Load
(
new
Safe
LoadModel
var
result
=
controller
.
Load
(
new
Wallet
LoadModel
{
Name
=
"myName"
,
FolderPath
=
""
,
...
...
@@ -95,25 +95,25 @@ namespace Breeze.Api.Tests
});
// Assert
mock
Safe
Wrapper
.
VerifyAll
();
mock
Wallet
Wrapper
.
VerifyAll
();
var
viewResult
=
Assert
.
IsType
<
JsonResult
>(
result
);
Assert
.
NotNull
(
viewResult
.
Value
);
Assert
.
IsType
<
Safe
Model
>(
viewResult
.
Value
);
Assert
.
IsType
<
Wallet
Model
>(
viewResult
.
Value
);
var
model
=
viewResult
.
Value
as
Safe
Model
;
var
model
=
viewResult
.
Value
as
Wallet
Model
;
Assert
.
Equal
(
"myWallet"
,
model
.
FileName
);
}
[
Fact
]
public
void
FileNotFoundExceptionandReturns404
()
{
var
mock
SafeWrapper
=
new
Mock
<
ISafe
Wrapper
>();
mock
SafeWrapper
.
Setup
(
safe
=>
safe
.
Load
(
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>())).
Throws
<
FileNotFoundException
>();
var
mock
WalletWrapper
=
new
Mock
<
IWallet
Wrapper
>();
mock
WalletWrapper
.
Setup
(
wallet
=>
wallet
.
Load
(
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>(),
It
.
IsAny
<
string
>())).
Throws
<
FileNotFoundException
>();
var
controller
=
new
SafeController
(
mockSafe
Wrapper
.
Object
);
var
controller
=
new
WalletController
(
mockWallet
Wrapper
.
Object
);
// Act
var
result
=
controller
.
Load
(
new
Safe
LoadModel
var
result
=
controller
.
Load
(
new
Wallet
LoadModel
{
Name
=
"myName"
,
FolderPath
=
""
,
...
...
@@ -121,7 +121,7 @@ namespace Breeze.Api.Tests
});
// Assert
mock
Safe
Wrapper
.
VerifyAll
();
mock
Wallet
Wrapper
.
VerifyAll
();
var
viewResult
=
Assert
.
IsType
<
ObjectResult
>(
result
);
Assert
.
NotNull
(
viewResult
);
Assert
.
Equal
(
404
,
viewResult
.
StatusCode
);
...
...
Breeze/src/Breeze.Api.Tests/Postman requests/Safe.postman_collection.json
View file @
d3b95586
{
"variables"
:
[],
"info"
:
{
"name"
:
"
Safe
"
,
"name"
:
"
Wallet
"
,
"_postman_id"
:
"11f915f1-7aac-bfeb-000c-b66348f4636f"
,
"description"
:
"Requests relating to operations on the
safe
"
,
"description"
:
"Requests relating to operations on the
wallet
"
,
"schema"
:
"https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item"
:
[
{
"name"
:
"Create
safe
- success"
,
"name"
:
"Create
wallet
- success"
,
"request"
:
{
"url"
:
"http://localhost:5000/api/
safe
/"
,
"url"
:
"http://localhost:5000/api/
wallet
/"
,
"method"
:
"POST"
,
"header"
:
[
{
...
...
@@ -28,9 +28,9 @@
"response"
:
[]
},
{
"name"
:
"Create
safe
- validation errors"
,
"name"
:
"Create
wallet
- validation errors"
,
"request"
:
{
"url"
:
"http://localhost:5000/api/
safe
/"
,
"url"
:
"http://localhost:5000/api/
wallet
/"
,
"method"
:
"POST"
,
"header"
:
[
{
...
...
@@ -48,9 +48,9 @@
"response"
:
[]
},
{
"name"
:
"Load
safe
"
,
"name"
:
"Load
wallet
"
,
"request"
:
{
"url"
:
"http://localhost:5000/api/
safe
/?password=123456&folderPath=MyWallets&name=myFirstWallet"
,
"url"
:
"http://localhost:5000/api/
wallet
/?password=123456&folderPath=MyWallets&name=myFirstWallet"
,
"method"
:
"GET"
,
"header"
:
[
{
...
...
@@ -68,9 +68,9 @@
"response"
:
[]
},
{
"name"
:
"Recover
safe
"
,
"name"
:
"Recover
wallet
"
,
"request"
:
{
"url"
:
"http://localhost:5000/api/
safe
/recover"
,
"url"
:
"http://localhost:5000/api/
wallet
/recover"
,
"method"
:
"POST"
,
"header"
:
[
{
...
...
Breeze/src/Breeze.Wallet/Controllers/
Safe
Controller.cs
→
Breeze/src/Breeze.Wallet/Controllers/
Wallet
Controller.cs
View file @
d3b95586
...
...
@@ -12,22 +12,22 @@ using Stratis.Bitcoin;
namespace
Breeze.Wallet.Controllers
{
[
Route
(
"api/[controller]"
)]
public
class
Safe
Controller
:
Controller
public
class
Wallet
Controller
:
Controller
{
private
readonly
I
SafeWrapper
safe
Wrapper
;
private
readonly
I
WalletWrapper
wallet
Wrapper
;
public
SafeController
(
ISafeWrapper
safe
Wrapper
)
public
WalletController
(
IWalletWrapper
wallet
Wrapper
)
{
this
.
safeWrapper
=
safe
Wrapper
;
this
.
walletWrapper
=
wallet
Wrapper
;
}
/// <summary>
/// Creates a new
safe
on the local machine.
/// Creates a new
wallet
on the local machine.
/// </summary>
/// <param name="
safe
Creation">The object containing the parameters used to create the wallet.</param>
/// <param name="
wallet
Creation">The object containing the parameters used to create the wallet.</param>
/// <returns>A JSON object containing the mnemonic created for the new wallet.</returns>
[
HttpPost
]
public
IActionResult
Create
([
FromBody
]
SafeCreationModel
safe
Creation
)
public
IActionResult
Create
([
FromBody
]
WalletCreationModel
wallet
Creation
)
{
// checks the request is valid
if
(!
this
.
ModelState
.
IsValid
)
...
...
@@ -38,7 +38,7 @@ namespace Breeze.Wallet.Controllers
try
{
var
mnemonic
=
this
.
safeWrapper
.
Create
(
safeCreation
.
Password
,
safeCreation
.
FolderPath
,
safeCreation
.
Name
,
safe
Creation
.
Network
);
var
mnemonic
=
this
.
walletWrapper
.
Create
(
walletCreation
.
Password
,
walletCreation
.
FolderPath
,
walletCreation
.
Name
,
wallet
Creation
.
Network
);
return
this
.
Json
(
mnemonic
);
}
catch
(
NotSupportedException
e
)
...
...
@@ -50,7 +50,7 @@ namespace Breeze.Wallet.Controllers
}
}
public
IActionResult
Load
(
SafeLoadModel
safe
Load
)
public
IActionResult
Load
(
WalletLoadModel
wallet
Load
)
{
// checks the request is valid
if
(!
this
.
ModelState
.
IsValid
)
...
...
@@ -61,8 +61,8 @@ namespace Breeze.Wallet.Controllers
try
{
var
safe
=
this
.
safeWrapper
.
Load
(
safeLoad
.
Password
,
safeLoad
.
FolderPath
,
safe
Load
.
Name
);
return
this
.
Json
(
safe
);
var
wallet
=
this
.
walletWrapper
.
Load
(
walletLoad
.
Password
,
walletLoad
.
FolderPath
,
wallet
Load
.
Name
);
return
this
.
Json
(
wallet
);
}
catch
(
FileNotFoundException
e
)
...
...
@@ -88,7 +88,7 @@ namespace Breeze.Wallet.Controllers
[
Route
(
"recover"
)]
[
HttpPost
]
public
IActionResult
Recover
([
FromBody
]
SafeRecoveryModel
safe
Recovery
)
public
IActionResult
Recover
([
FromBody
]
WalletRecoveryModel
wallet
Recovery
)
{
// checks the request is valid
if
(!
this
.
ModelState
.
IsValid
)
...
...
@@ -99,8 +99,8 @@ namespace Breeze.Wallet.Controllers
try
{
var
safe
=
this
.
safeWrapper
.
Recover
(
safeRecovery
.
Password
,
safeRecovery
.
FolderPath
,
safeRecovery
.
Name
,
safeRecovery
.
Network
,
safe
Recovery
.
Mnemonic
);
return
this
.
Json
(
safe
);
var
wallet
=
this
.
walletWrapper
.
Recover
(
walletRecovery
.
Password
,
walletRecovery
.
FolderPath
,
walletRecovery
.
Name
,
walletRecovery
.
Network
,
wallet
Recovery
.
Mnemonic
);
return
this
.
Json
(
wallet
);
}
catch
(
FileNotFoundException
e
)
...
...
Breeze/src/Breeze.Wallet/Models/
Safe
Creation.cs
→
Breeze/src/Breeze.Wallet/Models/
Wallet
Creation.cs
View file @
d3b95586
...
...
@@ -7,21 +7,21 @@ namespace Breeze.Wallet.Models
/// <summary>
/// Object used to create a new wallet
/// </summary>
public
class
Safe
CreationModel
public
class
Wallet
CreationModel
{
[
Required
(
ErrorMessage
=
"A password is required."
)]
public
string
Password
{
get
;
set
;
}
public
string
Network
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"The folder path where the
safe
will be created is required."
)]
[
Required
(
ErrorMessage
=
"The folder path where the
wallet
will be created is required."
)]
public
string
FolderPath
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"The name of the
safe
to create is missing."
)]
[
Required
(
ErrorMessage
=
"The name of the
wallet
to create is missing."
)]
public
string
Name
{
get
;
set
;
}
}
public
class
Safe
LoadModel
public
class
Wallet
LoadModel
{
[
Required
(
ErrorMessage
=
"A password is required."
)]
public
string
Password
{
get
;
set
;
}
...
...
@@ -29,11 +29,11 @@ namespace Breeze.Wallet.Models
[
Required
(
ErrorMessage
=
"The folder path is required."
)]
public
string
FolderPath
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"The name of the
safe
is missing."
)]
[
Required
(
ErrorMessage
=
"The name of the
wallet
is missing."
)]
public
string
Name
{
get
;
set
;
}
}
public
class
Safe
RecoveryModel
public
class
Wallet
RecoveryModel
{
[
Required
(
ErrorMessage
=
"A mnemonic is required."
)]
public
string
Mnemonic
{
get
;
set
;
}
...
...
@@ -44,7 +44,7 @@ namespace Breeze.Wallet.Models
[
Required
(
ErrorMessage
=
"The folder path is required."
)]
public
string
FolderPath
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"The name of the
safe
is missing."
)]
[
Required
(
ErrorMessage
=
"The name of the
wallet
is missing."
)]
public
string
Name
{
get
;
set
;
}
public
string
Network
{
get
;
set
;
}
...
...
Breeze/src/Breeze.Wallet/WalletFeature.cs
View file @
d3b95586
...
...
@@ -23,9 +23,9 @@ namespace Breeze.Wallet
.
AddFeature
<
WalletFeature
>()
.
FeatureServices
(
services
=>
{
services
.
AddTransient
<
I
SafeWrapper
,
Safe
Wrapper
>();
services
.
AddTransient
<
I
WalletWrapper
,
Wallet
Wrapper
>();
services
.
AddTransient
<
ITrackerWrapper
,
TrackerWrapper
>();
services
.
AddSingleton
<
Safe
Controller
>();
services
.
AddSingleton
<
Wallet
Controller
>();
});
});
...
...
Breeze/src/Breeze.Wallet/
Safe
Model.cs
→
Breeze/src/Breeze.Wallet/
Wallet
Model.cs
View file @
d3b95586
...
...
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
namespace
Breeze.Wallet
{
public
class
Safe
Model
public
class
Wallet
Model
{
public
string
Network
{
get
;
set
;
}
...
...
Breeze/src/Breeze.Wallet/Wrappers/I
Safe
Wrapper.cs
→
Breeze/src/Breeze.Wallet/Wrappers/I
Wallet
Wrapper.cs
View file @
d3b95586
...
...
@@ -4,12 +4,12 @@ namespace Breeze.Wallet.Wrappers
/// <summary>
/// An interface enabling wallet operations.
/// </summary>
public
interface
I
Safe
Wrapper
public
interface
I
Wallet
Wrapper
{
string
Create
(
string
password
,
string
folderPath
,
string
name
,
string
network
);
Safe
Model
Load
(
string
password
,
string
folderPath
,
string
name
);
Wallet
Model
Load
(
string
password
,
string
folderPath
,
string
name
);
Safe
Model
Recover
(
string
password
,
string
folderPath
,
string
name
,
string
network
,
string
mnemonic
);
Wallet
Model
Recover
(
string
password
,
string
folderPath
,
string
name
,
string
network
,
string
mnemonic
);
}
}
Breeze/src/Breeze.Wallet/Wrappers/
Safe
Wrapper.cs
→
Breeze/src/Breeze.Wallet/Wrappers/
Wallet
Wrapper.cs
View file @
d3b95586
...
...
@@ -6,64 +6,64 @@ using NBitcoin;
namespace
Breeze.Wallet.Wrappers
{
/// <summary>
/// An implementation of the <see cref="I
Safe
Wrapper"/> interface.
/// An implementation of the <see cref="I
Wallet
Wrapper"/> interface.
/// </summary>
public
class
SafeWrapper
:
ISafe
Wrapper
public
class
WalletWrapper
:
IWallet
Wrapper
{
/// <summary>
/// Creates a
safe
on the local device.
/// Creates a
wallet
on the local device.
/// </summary>
/// <param name="password">The user's password.</param>
/// <param name="folderPath">The folder where the
safe
will be saved.</param>
/// <param name="name">The name of the
safe
.</param>
/// <param name="network">The network for which to create a
safe
.</param>
/// <returns>A mnemonic allowing recovery of the
safe
.</returns>
/// <param name="folderPath">The folder where the
wallet
will be saved.</param>
/// <param name="name">The name of the
wallet
.</param>
/// <param name="network">The network for which to create a
wallet
.</param>
/// <returns>A mnemonic allowing recovery of the
wallet
.</returns>
public
string
Create
(
string
password
,
string
folderPath
,
string
name
,
string
network
)
{
Mnemonic
mnemonic
;
Safe
safe
=
Safe
.
Create
(
out
mnemonic
,
password
,
Path
.
Combine
(
folderPath
,
$"
{
name
}
.json"
),
this
.
GetNetwork
(
network
));
Safe
wallet
=
Safe
.
Create
(
out
mnemonic
,
password
,
Path
.
Combine
(
folderPath
,
$"
{
name
}
.json"
),
this
.
GetNetwork
(
network
));
return
mnemonic
.
ToString
();
}
/// <summary>
/// Loads a
safe
from the local device.
/// Loads a
wallet
from the local device.
/// </summary>
/// <param name="password">The user's password.</param>
/// <param name="folderPath">The folder where the
safe
will be loaded.</param>
/// <param name="name">The name of the
safe
.</param>
/// <returns>The
safe
loaded from the local device</returns>
public
Safe
Model
Load
(
string
password
,
string
folderPath
,
string
name
)
/// <param name="folderPath">The folder where the
wallet
will be loaded.</param>
/// <param name="name">The name of the
wallet
.</param>
/// <returns>The
wallet
loaded from the local device</returns>
public
Wallet
Model
Load
(
string
password
,
string
folderPath
,
string
name
)
{
Safe
safe
=
Safe
.
Load
(
password
,
Path
.
Combine
(
folderPath
,
$"
{
name
}
.json"
));
Safe
wallet
=
Safe
.
Load
(
password
,
Path
.
Combine
(
folderPath
,
$"
{
name
}
.json"
));
//TODO review here which data should be returned
return
new
Safe
Model
return
new
Wallet
Model
{
Network
=
safe
.
Network
.
Name
,
Addresses
=
safe
.
GetFirstNAddresses
(
10
).
Select
(
a
=>
a
.
ToWif
()),
FileName
=
safe
.
WalletFilePath
Network
=
wallet
.
Network
.
Name
,
Addresses
=
wallet
.
GetFirstNAddresses
(
10
).
Select
(
a
=>
a
.
ToWif
()),
FileName
=
wallet
.
WalletFilePath
};
}
/// <summary>
/// Recovers a
safe
from the local device.
/// Recovers a
wallet
from the local device.
/// </summary>
/// <param name="password">The user's password.</param>
/// <param name="folderPath">The folder where the
safe
will be loaded.</param>
/// <param name="name">The name of the
safe
.</param>
/// <param name="folderPath">The folder where the
wallet
will be loaded.</param>
/// <param name="name">The name of the
wallet
.</param>
/// <param name="network">The network in which to creae this wallet</param>
/// <param name="mnemonic">The user's mnemonic for the
safe
.</param>
/// <param name="mnemonic">The user's mnemonic for the
wallet
.</param>
/// <returns></returns>
public
Safe
Model
Recover
(
string
password
,
string
folderPath
,
string
name
,
string
network
,
string
mnemonic
)
public
Wallet
Model
Recover
(
string
password
,
string
folderPath
,
string
name
,
string
network
,
string
mnemonic
)
{
Safe
safe
=
Safe
.
Recover
(
new
Mnemonic
(
mnemonic
),
password
,
Path
.
Combine
(
folderPath
,
$"
{
name
}
.json"
),
this
.
GetNetwork
(
network
));
Safe
wallet
=
Safe
.
Recover
(
new
Mnemonic
(
mnemonic
),
password
,
Path
.
Combine
(
folderPath
,
$"
{
name
}
.json"
),
this
.
GetNetwork
(
network
));
//TODO review here which data should be returned
return
new
Safe
Model
return
new
Wallet
Model
{
Network
=
safe
.
Network
.
Name
,
Addresses
=
safe
.
GetFirstNAddresses
(
10
).
Select
(
a
=>
a
.
ToWif
()),
FileName
=
safe
.
WalletFilePath
Network
=
wallet
.
Network
.
Name
,
Addresses
=
wallet
.
GetFirstNAddresses
(
10
).
Select
(
a
=>
a
.
ToWif
()),
FileName
=
wallet
.
WalletFilePath
};
}
...
...
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