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
e4036778
Commit
e4036778
authored
May 02, 2017
by
Pieterjan Vanhoof
Committed by
GitHub
May 02, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #37 from bokobza/feature/history
Added get transactions history
parents
0a7b7a87
d8bcbeb8
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
151 additions
and
103 deletions
+151
-103
WalletController.cs
Breeze/src/Breeze.Wallet/Controllers/WalletController.cs
+21
-3
IWalletManager.cs
Breeze/src/Breeze.Wallet/IWalletManager.cs
+8
-1
RequestModels.cs
Breeze/src/Breeze.Wallet/Models/RequestModels.cs
+88
-0
WalletCreation.cs
Breeze/src/Breeze.Wallet/Models/WalletCreation.cs
+0
-79
WalletHistoryModel.cs
Breeze/src/Breeze.Wallet/Models/WalletHistoryModel.cs
+26
-15
Wallet.cs
Breeze/src/Breeze.Wallet/Wallet.cs
+1
-1
WalletManager.cs
Breeze/src/Breeze.Wallet/WalletManager.cs
+7
-4
No files found.
Breeze/src/Breeze.Wallet/Controllers/WalletController.cs
View file @
e4036778
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Net
;
...
...
@@ -176,11 +177,11 @@ namespace Breeze.Wallet.Controllers
/// <summary>
/// Retrieves the history of a wallet.
/// </summary>
/// <param name="
model">The name of the wallet
.</param>
/// <param name="
request">The request parameters
.</param>
/// <returns></returns>
[
Route
(
"history"
)]
[
HttpGet
]
public
IActionResult
GetHistory
([
FromQuery
]
Wallet
Name
model
)
public
IActionResult
GetHistory
([
FromQuery
]
Wallet
HistoryRequest
request
)
{
// checks the request is valid
if
(!
this
.
ModelState
.
IsValid
)
...
...
@@ -191,8 +192,25 @@ namespace Breeze.Wallet.Controllers
try
{
return
this
.
Json
(
this
.
walletManager
.
GetHistory
(
model
.
Name
));
WalletHistoryModel
model
=
new
WalletHistoryModel
{
Transactions
=
new
List
<
TransactionItem
>()};
var
accounts
=
this
.
walletManager
.
GetAccountsByCoinType
(
request
.
WalletName
,
request
.
CoinType
).
ToList
();
foreach
(
var
address
in
accounts
.
SelectMany
(
a
=>
a
.
ExternalAddresses
).
Concat
(
accounts
.
SelectMany
(
a
=>
a
.
InternalAddresses
)))
{
foreach
(
var
transaction
in
address
.
Transactions
)
{
model
.
Transactions
.
Add
(
new
TransactionItem
{
Amount
=
transaction
.
Amount
,
Confirmed
=
transaction
.
Confirmed
,
Timestamp
=
transaction
.
CreationTime
,
TransactionId
=
transaction
.
Id
,
Address
=
address
.
Address
});
}
}
return
this
.
Json
(
model
.
Transactions
.
OrderByDescending
(
t
=>
t
.
Timestamp
));
}
catch
(
Exception
e
)
{
...
...
Breeze/src/Breeze.Wallet/IWalletManager.cs
View file @
e4036778
using
System
;
using
System.Collections.Generic
;
using
Breeze.Wallet.Models
;
using
NBitcoin
;
...
...
@@ -75,7 +76,13 @@ namespace Breeze.Wallet
WalletBalanceModel
GetBalance
(
string
walletName
);
WalletHistoryModel
GetHistory
(
string
walletName
);
/// <summary>
/// Gets a list of accounts filtered by coin type.
/// </summary>
/// <param name="walletName">The name of the wallet to look into.</param>
/// <param name="coinType">The type of coin to filter by.</param>
/// <returns></returns>
IEnumerable
<
HdAccount
>
GetAccountsByCoinType
(
string
walletName
,
CoinType
coinType
);
WalletBuildTransactionModel
BuildTransaction
(
string
password
,
string
address
,
Money
amount
,
string
feeType
,
bool
allowUnconfirmed
);
...
...
Breeze/src/Breeze.Wallet/Models/RequestModels.cs
0 → 100644
View file @
e4036778
using
System.Collections
;
using
System.Collections.Generic
;
using
System.ComponentModel.DataAnnotations
;
namespace
Breeze.Wallet.Models
{
/// <summary>
/// Object used to create a new wallet
/// </summary>
public
class
WalletCreationRequest
{
[
Required
(
ErrorMessage
=
"A password is required."
)]
public
string
Password
{
get
;
set
;
}
public
string
Network
{
get
;
set
;
}
public
string
FolderPath
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"The name of the wallet to create is missing."
)]
public
string
Name
{
get
;
set
;
}
}
public
class
WalletLoadRequest
{
[
Required
(
ErrorMessage
=
"A password is required."
)]
public
string
Password
{
get
;
set
;
}
public
string
FolderPath
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"The name of the wallet is missing."
)]
public
string
Name
{
get
;
set
;
}
}
public
class
WalletRecoveryRequest
{
[
Required
(
ErrorMessage
=
"A mnemonic is required."
)]
public
string
Mnemonic
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"A password is required."
)]
public
string
Password
{
get
;
set
;
}
public
string
FolderPath
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"The name of the wallet is missing."
)]
public
string
Name
{
get
;
set
;
}
public
string
Network
{
get
;
set
;
}
}
public
class
WalletHistoryRequest
{
[
Required
(
ErrorMessage
=
"The name of the wallet is missing."
)]
public
string
WalletName
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"The type of coin for which history is requested is missing."
)]
public
CoinType
CoinType
{
get
;
set
;
}
}
public
class
WalletName
{
[
Required
(
ErrorMessage
=
"The name of the wallet is missing."
)]
public
string
Name
{
get
;
set
;
}
}
public
class
BuildTransactionRequest
{
[
Required
(
ErrorMessage
=
"A password is required."
)]
public
string
Password
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"A destination address is required."
)]
public
string
Address
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"An amount is required."
)]
public
string
Amount
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"A fee type is required. It can be 'low', 'medium' or 'high'."
)]
public
string
FeeType
{
get
;
set
;
}
public
bool
AllowUnconfirmed
{
get
;
set
;
}
}
public
class
SendTransactionRequest
{
[
Required
(
ErrorMessage
=
"A transaction in hexadecimal format is required."
)]
public
string
Hex
{
get
;
set
;
}
}
}
Breeze/src/Breeze.Wallet/Models/WalletCreation.cs
deleted
100644 → 0
View file @
0a7b7a87
using
System.Collections
;
using
System.Collections.Generic
;
using
System.ComponentModel.DataAnnotations
;
namespace
Breeze.Wallet.Models
{
/// <summary>
/// Object used to create a new wallet
/// </summary>
public
class
WalletCreationRequest
{
[
Required
(
ErrorMessage
=
"A password is required."
)]
public
string
Password
{
get
;
set
;
}
public
string
Network
{
get
;
set
;
}
public
string
FolderPath
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"The name of the wallet to create is missing."
)]
public
string
Name
{
get
;
set
;
}
}
public
class
WalletLoadRequest
{
[
Required
(
ErrorMessage
=
"A password is required."
)]
public
string
Password
{
get
;
set
;
}
public
string
FolderPath
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"The name of the wallet is missing."
)]
public
string
Name
{
get
;
set
;
}
}
public
class
WalletRecoveryRequest
{
[
Required
(
ErrorMessage
=
"A mnemonic is required."
)]
public
string
Mnemonic
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"A password is required."
)]
public
string
Password
{
get
;
set
;
}
public
string
FolderPath
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"The name of the wallet is missing."
)]
public
string
Name
{
get
;
set
;
}
public
string
Network
{
get
;
set
;
}
}
public
class
WalletName
{
[
Required
(
ErrorMessage
=
"The name of the wallet is missing."
)]
public
string
Name
{
get
;
set
;
}
}
public
class
BuildTransactionRequest
{
[
Required
(
ErrorMessage
=
"A password is required."
)]
public
string
Password
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"A destination address is required."
)]
public
string
Address
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"An amount is required."
)]
public
string
Amount
{
get
;
set
;
}
[
Required
(
ErrorMessage
=
"A fee type is required. It can be 'low', 'medium' or 'high'."
)]
public
string
FeeType
{
get
;
set
;
}
public
bool
AllowUnconfirmed
{
get
;
set
;
}
}
public
class
SendTransactionRequest
{
[
Required
(
ErrorMessage
=
"A transaction in hexadecimal format is required."
)]
public
string
Hex
{
get
;
set
;
}
}
}
Breeze/src/Breeze.Wallet/Models/WalletHistoryModel.cs
View file @
e4036778
using
System.Collections.Generic
;
using
System
;
using
System.Collections.Generic
;
using
Breeze.Wallet.JsonConverters
;
using
NBitcoin
;
using
NBitcoin.JsonConverters
;
using
Newtonsoft.Json
;
namespace
Breeze.Wallet.Models
...
...
@@ -12,8 +15,15 @@ namespace Breeze.Wallet.Models
public
class
TransactionItem
{
/// <summary>
/// The Base58 representation of this address.
/// </summary>
[
JsonProperty
(
PropertyName
=
"address"
)]
public
string
Address
{
get
;
set
;
}
[
JsonProperty
(
PropertyName
=
"txId"
)]
public
string
TransactionId
{
get
;
set
;
}
[
JsonConverter
(
typeof
(
UInt256JsonConverter
))]
public
uint256
TransactionId
{
get
;
set
;
}
[
JsonProperty
(
PropertyName
=
"amount"
)]
public
Money
Amount
{
get
;
set
;
}
...
...
@@ -22,6 +32,7 @@ namespace Breeze.Wallet.Models
public
bool
Confirmed
{
get
;
set
;
}
[
JsonProperty
(
PropertyName
=
"timestamp"
)]
public
string
Timestamp
{
get
;
set
;
}
[
JsonConverter
(
typeof
(
DateTimeOffsetConverter
))]
public
DateTimeOffset
Timestamp
{
get
;
set
;
}
}
}
Breeze/src/Breeze.Wallet/Wallet.cs
View file @
e4036778
...
...
@@ -223,7 +223,7 @@ namespace Breeze.Wallet
/// <summary>
/// The index of this scriptPubKey in the transaction it is contained.
/// </summary>
[
JsonProperty
(
PropertyName
=
"index"
)]
[
JsonProperty
(
PropertyName
=
"index"
,
NullValueHandling
=
NullValueHandling
.
Ignore
)]
public
int
?
Index
{
get
;
set
;
}
/// <summary>
...
...
Breeze/src/Breeze.Wallet/WalletManager.cs
View file @
e4036778
...
...
@@ -211,9 +211,12 @@ namespace Breeze.Wallet
throw
new
System
.
NotImplementedException
();
}
public
WalletHistoryModel
GetHistory
(
string
walletName
)
/// <inheritdoc />
public
IEnumerable
<
HdAccount
>
GetAccountsByCoinType
(
string
walletName
,
CoinType
coinType
)
{
throw
new
System
.
NotImplementedException
();
return
this
.
Wallets
.
SelectMany
(
w
=>
w
.
AccountsRoot
.
Where
(
a
=>
a
.
CoinType
==
coinType
)).
SelectMany
(
a
=>
a
.
Accounts
);
}
public
WalletBuildTransactionModel
BuildTransaction
(
string
password
,
string
address
,
Money
amount
,
string
feeType
,
bool
allowUnconfirmed
)
...
...
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