Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
destream-blockchain
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
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
destream-blockchain
Commits
07ea7d89
Commit
07ea7d89
authored
Dec 14, 2018
by
Sergei Zubov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix transaction without change
parent
06fd8d31
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
DeStreamTransactionBuilder.cs
Sources/NBitcoin/DeStreamTransactionBuilder.cs
+10
-6
No files found.
Sources/NBitcoin/DeStreamTransactionBuilder.cs
View file @
07ea7d89
...
@@ -23,16 +23,20 @@ namespace NBitcoin
...
@@ -23,16 +23,20 @@ namespace NBitcoin
{
{
IEnumerable
<
ICoin
>
result
=
base
.
BuildTransaction
(
ctx
,
group
,
builders
,
coins
,
zero
);
IEnumerable
<
ICoin
>
result
=
base
.
BuildTransaction
(
ctx
,
group
,
builders
,
coins
,
zero
);
if
(
ctx
.
Transaction
.
Inputs
.
Any
(
p
=>
p
.
PrevOut
.
Hash
==
uint256
.
Zero
))
if
(
ctx
.
Transaction
.
Inputs
.
Any
(
p
=>
p
.
PrevOut
.
Hash
==
uint256
.
Zero
))
return
result
;
return
result
;
// To secure that fee is charged from spending coins and not from change,
// To secure that fee is charged from spending coins and not from change,
// we add input with uint256.Zero hash that points to output with change
// we add input with uint256.Zero hash that points to output with change
int
changeIndex
=
ctx
.
Transaction
.
Outputs
.
FindIndex
(
p
=>
p
.
ScriptPubKey
==
group
.
ChangeScript
[(
int
)
ctx
.
ChangeType
]);
if
(
changeIndex
==
-
1
)
return
result
;
var
outPoint
=
new
OutPoint
var
outPoint
=
new
OutPoint
{
{
Hash
=
uint256
.
Zero
,
Hash
=
uint256
.
Zero
,
N
=
(
uint
)
ctx
.
Transaction
.
Outputs
.
FindIndex
(
p
=>
N
=
(
uint
)
changeIndex
p
.
ScriptPubKey
==
group
.
ChangeScript
[(
int
)
ctx
.
ChangeType
])
};
};
ctx
.
Transaction
.
AddInput
(
new
TxIn
ctx
.
Transaction
.
AddInput
(
new
TxIn
...
@@ -41,7 +45,7 @@ namespace NBitcoin
...
@@ -41,7 +45,7 @@ namespace NBitcoin
});
});
group
.
Coins
.
Add
(
outPoint
,
new
Coin
(
uint256
.
Zero
,
outPoint
.
N
,
group
.
Coins
.
Add
(
outPoint
,
new
Coin
(
uint256
.
Zero
,
outPoint
.
N
,
Money
.
Zero
,
group
.
ChangeScript
[(
int
)
ctx
.
ChangeType
]));
Money
.
Zero
,
@
group
.
ChangeScript
[(
int
)
ctx
.
ChangeType
]));
return
result
;
return
result
;
}
}
...
...
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