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
1e30455d
Commit
1e30455d
authored
May 10, 2017
by
Jeremy Bokobza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better history objects
parent
405ac690
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
8 deletions
+82
-8
WalletController.cs
Breeze/src/Breeze.Wallet/Controllers/WalletController.cs
+4
-3
IWalletManager.cs
Breeze/src/Breeze.Wallet/IWalletManager.cs
+18
-2
Wallet.cs
Breeze/src/Breeze.Wallet/Wallet.cs
+27
-0
WalletManager.cs
Breeze/src/Breeze.Wallet/WalletManager.cs
+33
-3
No files found.
Breeze/src/Breeze.Wallet/Controllers/WalletController.cs
View file @
1e30455d
...
@@ -198,8 +198,9 @@ namespace Breeze.Wallet.Controllers
...
@@ -198,8 +198,9 @@ namespace Breeze.Wallet.Controllers
{
{
WalletHistoryModel
model
=
new
WalletHistoryModel
{
Transactions
=
new
List
<
TransactionItem
>()
};
WalletHistoryModel
model
=
new
WalletHistoryModel
{
Transactions
=
new
List
<
TransactionItem
>()
};
var
accounts
=
this
.
walletManager
.
GetAccountsByCoinType
(
request
.
WalletName
,
request
.
CoinType
).
ToList
();
// get transactions contained in the wallet
foreach
(
var
address
in
accounts
.
SelectMany
(
a
=>
a
.
ExternalAddresses
).
Concat
(
accounts
.
SelectMany
(
a
=>
a
.
InternalAddresses
)))
var
addresses
=
this
.
walletManager
.
GetHistoryByCoinType
(
request
.
WalletName
,
request
.
CoinType
);
foreach
(
var
address
in
addresses
)
{
{
foreach
(
var
transaction
in
address
.
Transactions
)
foreach
(
var
transaction
in
address
.
Transactions
)
{
{
...
...
Breeze/src/Breeze.Wallet/IWalletManager.cs
View file @
1e30455d
...
@@ -97,6 +97,22 @@ namespace Breeze.Wallet
...
@@ -97,6 +97,22 @@ namespace Breeze.Wallet
/// <returns>An unused address or a newly created address, in Base58 format.</returns>
/// <returns>An unused address or a newly created address, in Base58 format.</returns>
string
GetUnusedAddress
(
string
walletName
,
CoinType
coinType
,
string
accountName
);
string
GetUnusedAddress
(
string
walletName
,
CoinType
coinType
,
string
accountName
);
/// <summary>
/// Gets a collection of addresses containing transactions for this coin.
/// </summary>
/// <param name="walletName">The name of the wallet to get history from.</param>
/// <param name="coinType">Type of the coin.</param>
/// <returns></returns>
IEnumerable
<
HdAddress
>
GetHistoryByCoinType
(
string
walletName
,
CoinType
coinType
);
/// <summary>
/// Gets a collection of addresses containing transactions for this coin.
/// </summary>
/// <param name="wallet">The wallet to get history from.</param>
/// <param name="coinType">Type of the coin.</param>
/// <returns></returns>
IEnumerable
<
HdAddress
>
GetHistoryByCoinType
(
Wallet
wallet
,
CoinType
coinType
);
WalletGeneralInfoModel
GetGeneralInfo
(
string
walletName
);
WalletGeneralInfoModel
GetGeneralInfo
(
string
walletName
);
/// <summary>
/// <summary>
...
...
Breeze/src/Breeze.Wallet/Wallet.cs
View file @
1e30455d
...
@@ -57,6 +57,33 @@ namespace Breeze.Wallet
...
@@ -57,6 +57,33 @@ namespace Breeze.Wallet
/// </summary>
/// </summary>
[
JsonProperty
(
PropertyName
=
"accountsRoot"
)]
[
JsonProperty
(
PropertyName
=
"accountsRoot"
)]
public
IEnumerable
<
AccountRoot
>
AccountsRoot
{
get
;
set
;
}
public
IEnumerable
<
AccountRoot
>
AccountsRoot
{
get
;
set
;
}
/// <summary>
/// Gets the type of the accounts by coin.
/// </summary>
/// <param name="coinType">Type of the coin.</param>
/// <returns></returns>
public
IEnumerable
<
HdAccount
>
GetAccountsByCoinType
(
CoinType
coinType
)
{
return
this
.
AccountsRoot
.
Where
(
a
=>
a
.
CoinType
==
coinType
).
SelectMany
(
a
=>
a
.
Accounts
);
}
/// <summary>
/// Gets all the transactions by coin type.
/// </summary>
/// <param name="coinType">Type of the coin.</param>
/// <returns></returns>
public
IEnumerable
<
TransactionData
>
GetAllTransactionsByCoinType
(
CoinType
coinType
)
{
List
<
TransactionData
>
result
=
new
List
<
TransactionData
>();
var
accounts
=
this
.
GetAccountsByCoinType
(
coinType
).
ToList
();
foreach
(
var
address
in
accounts
.
SelectMany
(
a
=>
a
.
ExternalAddresses
).
Concat
(
accounts
.
SelectMany
(
a
=>
a
.
InternalAddresses
)))
{
result
.
AddRange
(
address
.
Transactions
);
}
return
result
;
}
}
}
/// <summary>
/// <summary>
...
...
Breeze/src/Breeze.Wallet/WalletManager.cs
View file @
1e30455d
...
@@ -242,6 +242,32 @@ namespace Breeze.Wallet
...
@@ -242,6 +242,32 @@ namespace Breeze.Wallet
return
account
.
GetFirstUnusedExternalAddress
().
Address
;
return
account
.
GetFirstUnusedExternalAddress
().
Address
;
}
}
/// <inheritdoc />
public
IEnumerable
<
HdAddress
>
GetHistoryByCoinType
(
string
walletName
,
CoinType
coinType
)
{
Wallet
wallet
=
this
.
Wallets
.
SingleOrDefault
(
w
=>
w
.
Name
==
walletName
);
if
(
wallet
==
null
)
{
throw
new
Exception
(
$"No wallet with name
{
walletName
}
could be found."
);
}
return
this
.
GetHistoryByCoinType
(
wallet
,
coinType
);
}
/// <inheritdoc />
public
IEnumerable
<
HdAddress
>
GetHistoryByCoinType
(
Wallet
wallet
,
CoinType
coinType
)
{
var
accounts
=
wallet
.
GetAccountsByCoinType
(
coinType
).
ToList
();
foreach
(
var
address
in
accounts
.
SelectMany
(
a
=>
a
.
ExternalAddresses
).
Concat
(
accounts
.
SelectMany
(
a
=>
a
.
InternalAddresses
)))
{
if
(
address
.
Transactions
.
Any
())
{
yield
return
address
;
}
}
}
/// <summary>
/// <summary>
/// Creates a number of addresses in the provided account.
/// Creates a number of addresses in the provided account.
/// </summary>
/// </summary>
...
@@ -301,9 +327,13 @@ namespace Breeze.Wallet
...
@@ -301,9 +327,13 @@ namespace Breeze.Wallet
/// <inheritdoc />
/// <inheritdoc />
public
IEnumerable
<
HdAccount
>
GetAccountsByCoinType
(
string
walletName
,
CoinType
coinType
)
public
IEnumerable
<
HdAccount
>
GetAccountsByCoinType
(
string
walletName
,
CoinType
coinType
)
{
{
return
this
.
Wallets
.
Wallet
wallet
=
this
.
Wallets
.
SingleOrDefault
(
w
=>
w
.
Name
==
walletName
);
SelectMany
(
w
=>
w
.
AccountsRoot
.
Where
(
a
=>
a
.
CoinType
==
coinType
)).
if
(
wallet
==
null
)
SelectMany
(
a
=>
a
.
Accounts
);
{
throw
new
Exception
(
$"No wallet with name
{
walletName
}
could be found."
);
}
return
wallet
.
GetAccountsByCoinType
(
coinType
);
}
}
public
WalletBuildTransactionModel
BuildTransaction
(
string
password
,
string
address
,
Money
amount
,
string
feeType
,
bool
allowUnconfirmed
)
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