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
a17b5dd1
Commit
a17b5dd1
authored
May 15, 2017
by
Pieterjan Vanhoof
Committed by
GitHub
May 15, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #53 from bokobza/feature/build-transaction
Fixed inserting the tx twice
parents
36cf64fb
821cc8c8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
13 deletions
+27
-13
WalletManager.cs
Breeze/src/Breeze.Wallet/WalletManager.cs
+27
-13
No files found.
Breeze/src/Breeze.Wallet/WalletManager.cs
View file @
a17b5dd1
...
...
@@ -491,24 +491,38 @@ namespace Breeze.Wallet
/// <param name="spendingTransactionIndex">The index of the output in the transaction being referenced, if this is a spending transaction.</param>
private
void
AddTransactionToWallet
(
uint256
transactionHash
,
uint
time
,
int
?
index
,
Money
amount
,
Script
script
,
int
?
blockHeight
=
null
,
uint
?
blockTime
=
null
,
uint256
spendingTransactionId
=
null
,
int
?
spendingTransactionIndex
=
null
)
{
// get the collection of transactions to add to.
this
.
keysLookup
.
TryGetValue
(
script
,
out
ICollection
<
TransactionData
>
trans
);
trans
.
Add
(
new
TransactionData
// if it's the first time we see this transaction
if
(
trans
!=
null
&&
trans
.
All
(
t
=>
t
.
Id
!=
transactionHash
))
{
Amount
=
amount
,
BlockHeight
=
blockHeight
,
Confirmed
=
blockHeight
.
HasValue
,
Id
=
transactionHash
,
CreationTime
=
DateTimeOffset
.
FromUnixTimeMilliseconds
(
blockTime
??
time
),
Index
=
index
});
trans
.
Add
(
new
TransactionData
{
Amount
=
amount
,
BlockHeight
=
blockHeight
,
Confirmed
=
blockHeight
.
HasValue
,
Id
=
transactionHash
,
CreationTime
=
DateTimeOffset
.
FromUnixTimeMilliseconds
(
blockTime
??
time
),
Index
=
index
});
// if this is a spending transaction, mark the spent transaction as such
if
(
spendingTransactionId
!=
null
)
// if this is a spending transaction, mark the spent transaction as such
if
(
spendingTransactionId
!=
null
)
{
var
transactions
=
this
.
keysLookup
.
Values
.
SelectMany
(
v
=>
v
).
Where
(
t
=>
t
.
Id
==
spendingTransactionId
);
if
(
transactions
.
Any
())
{
transactions
.
Single
(
t
=>
t
.
Index
==
spendingTransactionIndex
).
SpentInTransaction
=
transactionHash
;
}
}
}
else
if
(
trans
.
Any
(
t
=>
t
.
Id
==
transactionHash
&&
!
t
.
Confirmed
))
// if this is an unconfirmed transaction now received in a block
{
var
transactions
=
this
.
keysLookup
.
Values
.
SelectMany
(
v
=>
v
).
Where
(
t
=>
t
.
Id
==
spendingTransactionI
d
);
if
(
transactions
.
Any
()
)
var
foundTransaction
=
trans
.
Single
(
t
=>
t
.
Id
==
transactionHash
&&
!
t
.
Confirme
d
);
if
(
blockHeight
!=
null
)
{
transactions
.
Single
(
t
=>
t
.
Index
==
spendingTransactionIndex
).
SpentInTransaction
=
transactionHash
;
foundTransaction
.
Confirmed
=
true
;
}
}
...
...
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