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
Hide 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
{
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
)))
// get transactions contained in the wallet
var
addresses
=
this
.
walletManager
.
GetHistoryByCoinType
(
request
.
WalletName
,
request
.
CoinType
);
foreach
(
var
address
in
addresses
)
{
foreach
(
var
transaction
in
address
.
Transactions
)
{
...
...
@@ -213,7 +214,7 @@ namespace Breeze.Wallet.Controllers
});
}
}
model
.
Transactions
=
model
.
Transactions
.
OrderByDescending
(
t
=>
t
.
Timestamp
).
ToList
();
return
this
.
Json
(
model
);
}
...
...
Breeze/src/Breeze.Wallet/IWalletManager.cs
View file @
1e30455d
...
...
@@ -74,7 +74,7 @@ namespace Breeze.Wallet
/// </remarks>
/// <returns>An unused account.</returns>
HdAccount
GetUnusedAccount
(
Wallet
wallet
,
CoinType
coinType
,
string
password
);
/// <summary>
/// Creates a new account.
/// </summary>
...
...
@@ -97,6 +97,22 @@ namespace Breeze.Wallet
/// <returns>An unused address or a newly created address, in Base58 format.</returns>
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
);
/// <summary>
...
...
@@ -126,6 +142,6 @@ namespace Breeze.Wallet
/// <param name="transaction">The transaction.</param>
/// <param name="blockHeight">The height of the block this transaction came from. Null if it was not a transaction included in a block.</param>
/// <param name="blockTime">The block time.</param>
void
ProcessTransaction
(
CoinType
coinType
,
NBitcoin
.
Transaction
transaction
,
int
?
blockHeight
=
null
,
uint
?
blockTime
=
null
);
void
ProcessTransaction
(
CoinType
coinType
,
NBitcoin
.
Transaction
transaction
,
int
?
blockHeight
=
null
,
uint
?
blockTime
=
null
);
}
}
Breeze/src/Breeze.Wallet/Wallet.cs
View file @
1e30455d
...
...
@@ -57,6 +57,33 @@ namespace Breeze.Wallet
/// </summary>
[
JsonProperty
(
PropertyName
=
"accountsRoot"
)]
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>
...
...
Breeze/src/Breeze.Wallet/WalletManager.cs
View file @
1e30455d
...
...
@@ -242,6 +242,32 @@ namespace Breeze.Wallet
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>
/// Creates a number of addresses in the provided account.
/// </summary>
...
...
@@ -301,9 +327,13 @@ namespace Breeze.Wallet
/// <inheritdoc />
public
IEnumerable
<
HdAccount
>
GetAccountsByCoinType
(
string
walletName
,
CoinType
coinType
)
{
return
this
.
Wallets
.
SelectMany
(
w
=>
w
.
AccountsRoot
.
Where
(
a
=>
a
.
CoinType
==
coinType
)).
SelectMany
(
a
=>
a
.
Accounts
);
Wallet
wallet
=
this
.
Wallets
.
SingleOrDefault
(
w
=>
w
.
Name
==
walletName
);
if
(
wallet
==
null
)
{
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
)
...
...
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