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
6ab3dbb1
Commit
6ab3dbb1
authored
May 17, 2017
by
Jeremy Bokobza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
For spending transactions, added a record of the payments made out to other scripts
parent
636cc76a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
9 deletions
+60
-9
Wallet.cs
Breeze/src/Breeze.Wallet/Wallet.cs
+33
-4
WalletManager.cs
Breeze/src/Breeze.Wallet/WalletManager.cs
+27
-5
No files found.
Breeze/src/Breeze.Wallet/Wallet.cs
View file @
6ab3dbb1
...
...
@@ -156,9 +156,6 @@ namespace Breeze.Wallet
}
return
account
;
}
}
/// <summary>
...
...
@@ -417,6 +414,12 @@ namespace Breeze.Wallet
[
JsonConverter
(
typeof
(
MoneyJsonConverter
))]
public
Money
Amount
{
get
;
set
;
}
/// <summary>
/// A list of payments made out in this transaction.
/// </summary>
[
JsonProperty
(
PropertyName
=
"payments"
,
NullValueHandling
=
NullValueHandling
.
Ignore
)]
public
ICollection
<
PaymentDetails
>
Payments
{
get
;
set
;
}
/// <summary>
/// The index of this scriptPubKey in the transaction it is contained.
/// </summary>
...
...
@@ -444,4 +447,30 @@ namespace Breeze.Wallet
return
this
.
BlockHeight
!=
null
;
}
}
/// <summary>
/// An object representing a payment.
/// </summary>
public
class
PaymentDetails
{
/// <summary>
/// The script pub key of the destination address.
/// </summary>
[
JsonProperty
(
PropertyName
=
"destinationScriptPubKey"
)]
[
JsonConverter
(
typeof
(
ScriptJsonConverter
))]
public
Script
DestinationScriptPubKey
{
get
;
set
;
}
/// <summary>
/// The Base58 representation of the destination address.
/// </summary>
[
JsonProperty
(
PropertyName
=
"destinationAddress"
)]
public
string
DestinationAddress
{
get
;
set
;
}
/// <summary>
/// The transaction amount.
/// </summary>
[
JsonProperty
(
PropertyName
=
"amount"
)]
[
JsonConverter
(
typeof
(
MoneyJsonConverter
))]
public
Money
Amount
{
get
;
set
;
}
}
}
\ No newline at end of file
Breeze/src/Breeze.Wallet/WalletManager.cs
View file @
6ab3dbb1
...
...
@@ -476,7 +476,11 @@ namespace Breeze.Wallet
// find the script this input references
var
keyToSpend
=
this
.
keysLookup
.
Single
(
v
=>
v
.
Value
.
Transactions
.
Contains
(
tTx
)).
Key
;
AddTransactionToWallet
(
transaction
.
GetHash
(),
transaction
.
Time
,
null
,
-
tTx
.
Amount
,
keyToSpend
,
blockHeight
,
blockTime
,
tTx
.
Id
,
tTx
.
Index
);
// get the details of the outputs paid out
IEnumerable
<
TxOut
>
paidoutto
=
transaction
.
Outputs
.
Where
(
o
=>
!
this
.
keysLookup
.
Keys
.
Contains
(
o
.
ScriptPubKey
));
AddTransactionToWallet
(
transaction
.
GetHash
(),
transaction
.
Time
,
null
,
-
tTx
.
Amount
,
keyToSpend
,
blockHeight
,
blockTime
,
tTx
.
Id
,
tTx
.
Index
,
paidoutto
);
}
}
...
...
@@ -492,7 +496,7 @@ namespace Breeze.Wallet
/// <param name="blockTime">The block time.</param>
/// <param name="spendingTransactionId">The id of the transaction containing the output being spent, if this is a spending transaction.</param>
/// <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
)
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
,
IEnumerable
<
TxOut
>
paidToOutputs
=
null
)
{
// get the collection of transactions to add to.
this
.
keysLookup
.
TryGetValue
(
script
,
out
HdAddress
address
);
...
...
@@ -502,14 +506,32 @@ namespace Breeze.Wallet
// if it's the first time we see this transaction
if
(
trans
.
All
(
t
=>
t
.
Id
!=
transactionHash
))
{
trans
.
Add
(
new
TransactionData
var
newTransaction
=
new
TransactionData
{
Amount
=
amount
,
BlockHeight
=
blockHeight
,
Id
=
transactionHash
,
CreationTime
=
DateTimeOffset
.
FromUnixTimeMilliseconds
(
blockTime
??
time
),
Index
=
index
};
trans
.
Add
(
newTransaction
);
// if this is a spending transaction, keep a record of the payments made out to other scripts.
if
(
paidToOutputs
!=
null
&&
paidToOutputs
.
Any
())
{
List
<
PaymentDetails
>
payments
=
new
List
<
PaymentDetails
>();
foreach
(
var
paidToOutput
in
paidToOutputs
)
{
payments
.
Add
(
new
PaymentDetails
{
DestinationScriptPubKey
=
paidToOutput
.
ScriptPubKey
,
DestinationAddress
=
paidToOutput
.
ScriptPubKey
.
GetDestinationAddress
(
this
.
network
).
ToString
(),
Amount
=
paidToOutput
.
Value
});
}
newTransaction
.
Payments
=
payments
;
}
// if this is a spending transaction, mark the spent transaction as such
if
(
spendingTransactionId
!=
null
)
...
...
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