Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
destream-blockchain
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
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
destream-blockchain
Commits
1b5310fa
Commit
1b5310fa
authored
Mar 25, 2019
by
Sergei Zubov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add newaddress request
parent
2fc62ee9
Pipeline
#152
failed with stage
in 1 minute and 39 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
1 deletion
+38
-1
DeStreamWalletController.cs
...n.Features.Wallet/Controllers/DeStreamWalletController.cs
+27
-1
DeStreamWalletManager.cs
.../Stratis.Bitcoin.Features.Wallet/DeStreamWalletManager.cs
+9
-0
IDeStreamWalletManager.cs
...coin.Features.Wallet/Interfaces/IDeStreamWalletManager.cs
+2
-0
No files found.
Sources/Stratis.Bitcoin.Features.Wallet/Controllers/DeStreamWalletController.cs
View file @
1b5310fa
...
...
@@ -22,13 +22,15 @@ namespace Stratis.Bitcoin.Features.Wallet.Controllers
private
readonly
ILogger
_logger
;
private
readonly
DeStreamNetwork
_network
;
private
readonly
IWalletTransactionHandler
_walletTransactionHandler
;
private
readonly
IDeStreamWalletManager
_walletManager
;
public
DeStreamWalletController
(
Network
network
,
IWalletTransactionHandler
walletTransactionHandler
,
ILoggerFactory
loggerFactory
)
ILoggerFactory
loggerFactory
,
IDeStreamWalletManager
walletManager
)
{
this
.
_network
=
(
DeStreamNetwork
)
network
??
throw
new
NotSupportedException
(
$"Network must be
{
nameof
(
NBitcoin
.
DeStreamNetwork
)}
"
);
this
.
_walletTransactionHandler
=
walletTransactionHandler
;
this
.
_walletManager
=
walletManager
;
this
.
_logger
=
loggerFactory
.
CreateLogger
(
GetType
().
FullName
);
}
...
...
@@ -139,6 +141,30 @@ namespace Stratis.Bitcoin.Features.Wallet.Controllers
}
}
[
Route
(
"newaddress"
)]
[
HttpGet
]
public
IActionResult
GetNewAddress
([
FromQuery
]
GetNewAddressModel
request
)
{
Guard
.
NotNull
(
request
,
nameof
(
request
));
// checks the request is valid
if
(!
this
.
ModelState
.
IsValid
)
{
return
ModelStateErrors
.
BuildErrorResponse
(
this
.
ModelState
);
}
try
{
return
this
.
Json
(
this
.
_walletManager
.
CreateAddress
(
new
WalletAccountReference
(
request
.
WalletName
,
request
.
AccountName
)));
}
catch
(
Exception
e
)
{
this
.
_logger
.
LogError
(
"Exception occurred: {0}"
,
e
.
ToString
());
return
ErrorHelpers
.
BuildErrorResponse
(
HttpStatusCode
.
BadRequest
,
e
.
Message
,
e
.
ToString
());
}
}
/// <summary>
/// Modifies transfer funds amount according to fee type.
/// For <see cref="DeStreamFeeType.Extra" /> fee type, fee is subtracted from transfer funds.
...
...
Sources/Stratis.Bitcoin.Features.Wallet/DeStreamWalletManager.cs
View file @
1b5310fa
...
...
@@ -95,5 +95,14 @@ namespace Stratis.Bitcoin.Features.Wallet
spentTransaction
.
SpendingDetails
=
spendingDetails
;
spentTransaction
.
MerkleProof
=
null
;
}
public
HdAddress
CreateAddress
(
WalletAccountReference
accountReference
)
{
Guard
.
NotNull
(
accountReference
,
nameof
(
accountReference
));
return
this
.
GetWalletByName
(
accountReference
.
WalletName
)
.
GetAccountByCoinType
(
accountReference
.
AccountName
,
this
.
coinType
).
CreateAddresses
(
this
.
network
,
1
)
.
Single
();
}
}
}
\ No newline at end of file
Sources/Stratis.Bitcoin.Features.Wallet/Interfaces/IDeStreamWalletManager.cs
View file @
1b5310fa
...
...
@@ -6,5 +6,7 @@
/// Processes genesis block
/// </summary>
void
ProcessGenesisBlock
();
HdAddress
CreateAddress
(
WalletAccountReference
accountReference
);
}
}
\ No newline at end of file
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