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
73573c27
Commit
73573c27
authored
Sep 24, 2019
by
Sergei Zubov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' into 'release'
Add fee free transactions to own addresses See merge request
!1
parents
3dafe424
b077bb71
Pipeline
#745
failed with stages
in 45 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
434 additions
and
50 deletions
+434
-50
.gitlab-ci.yml
.gitlab-ci.yml
+0
-20
DeStreamTransactionBuilder.cs
Sources/NBitcoin/DeStreamTransactionBuilder.cs
+35
-11
TransactionBuilder.cs
Sources/NBitcoin/TransactionBuilder.cs
+7
-0
PowMining.cs
Sources/Stratis.Bitcoin.Features.Miner/PowMining.cs
+1
-1
DeStreamWalletManager.cs
.../Stratis.Bitcoin.Features.Wallet/DeStreamWalletManager.cs
+9
-0
DeStreamWalletTransactionHandler.cs
...tcoin.Features.Wallet/DeStreamWalletTransactionHandler.cs
+40
-2
IDeStreamWalletManager.cs
...coin.Features.Wallet/Interfaces/IDeStreamWalletManager.cs
+5
-1
DeStreamMain.cs
Sources/Stratis.Bitcoin.Networks/DeStreamMain.cs
+1
-1
app.tpl.yml
app.tpl.yml
+336
-14
No files found.
.gitlab-ci.yml
View file @
73573c27
...
...
@@ -10,11 +10,6 @@ stages:
build_dev
:
stage
:
build_dev
image
:
docker:stable
services
:
-
docker:dind
variables
:
DOCKER_HOST
:
tcp://docker:2375
DOCKER_DRIVER
:
overlay2
script
:
-
docker login -u "gitlab-ci-token" -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
-
docker build -t ${CI_REGISTRY_IMAGE}/dev:${CI_PIPELINE_ID} .
...
...
@@ -30,11 +25,6 @@ build_dev:
build_test
:
stage
:
build_test
image
:
docker:stable
services
:
-
docker:dind
variables
:
DOCKER_HOST
:
tcp://docker:2375
DOCKER_DRIVER
:
overlay2
script
:
-
docker login -u "gitlab-ci-token" -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
-
docker build -t ${CI_REGISTRY_IMAGE}/test:${CI_PIPELINE_ID} .
...
...
@@ -70,11 +60,6 @@ build_prod:
deploy_to_test
:
stage
:
deploy_to_test
image
:
docker:stable
services
:
-
docker:dind
variables
:
DOCKER_HOST
:
tcp://docker:2375
DOCKER_DRIVER
:
overlay2
script
:
-
sed 's|_IMAGE_NAME_|'"${CI_REGISTRY_IMAGE}/test"'|g; s|_VERSION_|'"${CI_PIPELINE_ID}"'|g' app.tpl.yml > app.yml; cat app.yml
-
wget https://storage.googleapis.com/kubernetes-release/release/v1.13.3/bin/linux/amd64/kubectl && chmod +x ./kubectl
...
...
@@ -92,11 +77,6 @@ deploy_to_test:
run_test
:
stage
:
run_tests
image
:
docker:stable
services
:
-
docker:dind
variables
:
DOCKER_HOST
:
tcp://docker:2375
DOCKER_DRIVER
:
overlay2
script
:
-
docker build -f Dockerfile-tests .
allow_failure
:
true
...
...
Sources/NBitcoin/DeStreamTransactionBuilder.cs
View file @
73573c27
...
...
@@ -33,22 +33,46 @@ namespace NBitcoin
// 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
if
(
changeIndex
!=
-
1
)
{
Hash
=
uint256
.
Zero
,
N
=
(
uint
)
changeIndex
};
var
outPoint
=
new
OutPoint
{
Hash
=
uint256
.
Zero
,
N
=
(
uint
)
changeIndex
};
ctx
.
Transaction
.
AddInput
(
new
TxIn
ctx
.
Transaction
.
AddInput
(
new
TxIn
{
PrevOut
=
outPoint
});
group
.
Coins
.
Add
(
outPoint
,
new
Coin
(
uint256
.
Zero
,
outPoint
.
N
,
Money
.
Zero
,
group
.
ChangeScript
[(
int
)
ctx
.
ChangeType
]));
}
foreach
(
var
ownAddress
in
group
.
ownAddresses
)
{
PrevOut
=
outPoint
});
var
ownAddressOutputIndex
=
ctx
.
Transaction
.
Outputs
.
FindIndex
(
p
=>
string
.
Equals
(
p
.
ScriptPubKey
.
GetDestinationAddress
(
this
.
Network
).
ToString
(),
ownAddress
));
if
(
ownAddressOutputIndex
==
-
1
||
ownAddressOutputIndex
==
changeIndex
)
continue
;
var
outPoint
=
new
OutPoint
{
Hash
=
uint256
.
Zero
,
N
=
(
uint
)
ownAddressOutputIndex
};
ctx
.
Transaction
.
AddInput
(
new
TxIn
{
PrevOut
=
outPoint
});
group
.
Coins
.
Add
(
outPoint
,
new
Coin
(
uint256
.
Zero
,
outPoint
.
N
,
Money
.
Zero
,
@group
.
ChangeScript
[(
int
)
ctx
.
ChangeType
]));
group
.
Coins
.
Add
(
outPoint
,
new
Coin
(
uint256
.
Zero
,
outPoint
.
N
,
Money
.
Zero
,
ctx
.
Transaction
.
Outputs
[
ownAddressOutputIndex
].
ScriptPubKey
));
}
return
result
;
}
...
...
Sources/NBitcoin/TransactionBuilder.cs
View file @
73573c27
...
...
@@ -495,6 +495,7 @@ namespace NBitcoin
internal
List
<
Builder
>
IssuanceBuilders
=
new
List
<
Builder
>();
internal
Dictionary
<
AssetId
,
List
<
Builder
>>
BuildersByAsset
=
new
Dictionary
<
AssetId
,
List
<
Builder
>>();
internal
Script
[]
ChangeScript
=
new
Script
[
3
];
internal
IEnumerable
<
string
>
ownAddresses
{
get
;
set
;
}
internal
void
Shuffle
()
{
Shuffle
(
this
.
Builders
);
...
...
@@ -1074,6 +1075,12 @@ namespace NBitcoin
return
this
;
}
public
TransactionBuilder
SetOwnAddresses
(
IEnumerable
<
string
>
ownAddresses
)
{
this
.
CurrentGroup
.
ownAddresses
=
ownAddresses
;
return
this
;
}
public
TransactionBuilder
SetCoinSelector
(
ICoinSelector
selector
)
{
if
(
selector
==
null
)
...
...
Sources/Stratis.Bitcoin.Features.Miner/PowMining.cs
View file @
73573c27
...
...
@@ -47,7 +47,7 @@ namespace Stratis.Bitcoin.Features.Miner
private
readonly
IDateTimeProvider
dateTimeProvider
;
/// <summary>Default for "-blockmintxfee", which sets the minimum feerate for a transaction in blocks created by mining code.</summary>
public
const
int
DefaultBlockMinTxFee
=
100
0
;
public
const
int
DefaultBlockMinTxFee
=
0
;
private
uint256
hashPrevBlock
;
...
...
Sources/Stratis.Bitcoin.Features.Wallet/DeStreamWalletManager.cs
View file @
73573c27
...
...
@@ -110,5 +110,14 @@ namespace Stratis.Bitcoin.Features.Wallet
return
newAddress
;
}
public
IEnumerable
<
string
>
GetOwnAddresses
(
WalletAccountReference
accountReference
)
{
return
GetAccounts
(
accountReference
.
WalletName
)
.
Single
(
q
=>
q
.
Name
==
accountReference
.
AccountName
).
ExternalAddresses
.
Select
(
q
=>
q
.
Address
).
Concat
(
GetAccounts
(
accountReference
.
WalletName
)
.
Single
(
q
=>
q
.
Name
==
accountReference
.
AccountName
).
InternalAddresses
.
Select
(
q
=>
q
.
Address
));
}
}
}
\ No newline at end of file
Sources/Stratis.Bitcoin.Features.Wallet/DeStreamWalletTransactionHandler.cs
View file @
73573c27
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Security
;
...
...
@@ -30,10 +30,25 @@ namespace Stratis.Bitcoin.Features.Wallet
}
}
protected
override
void
InitializeTransactionBuilder
(
TransactionBuildContext
context
)
{
base
.
InitializeTransactionBuilder
(
context
);
this
.
AddOwnAddresses
(
context
);
}
private
void
AddOwnAddresses
(
TransactionBuildContext
context
)
{
context
.
TransactionBuilder
.
SetOwnAddresses
(
(
this
.
walletManager
as
IDeStreamWalletManager
).
GetOwnAddresses
(
context
.
AccountReference
));
}
/// <inheritdoc />
protected
override
void
AddFee
(
TransactionBuildContext
context
)
{
long
fee
=
Convert
.
ToInt64
(
context
.
Recipients
.
Sum
(
p
=>
p
.
Amount
)
*
this
.
DeStreamNetwork
.
FeeRate
);
var
fundTransfers
=
context
.
Recipients
.
Where
(
p
=>
!(
this
.
walletManager
as
IDeStreamWalletManager
).
GetOwnAddresses
(
context
.
AccountReference
)
.
Contains
(
p
.
ScriptPubKey
.
GetDestinationAddress
(
this
.
network
).
ToString
()));
long
fee
=
Convert
.
ToInt64
(
fundTransfers
.
Sum
(
p
=>
p
.
Amount
)
*
this
.
DeStreamNetwork
.
FeeRate
);
context
.
TransactionFee
=
fee
;
context
.
TransactionBuilder
.
SendFees
(
fee
);
}
...
...
@@ -137,6 +152,29 @@ namespace Stratis.Bitcoin.Features.Wallet
seedExtKey
.
Derive
(
new
KeyPath
(
context
.
ChangeAddress
.
HdPath
)).
GetWif
(
wallet
.
Network
);
signingKeys
.
Add
(
changeAddressPrivateKey
);
var
transfersToSelf
=
context
.
Recipients
.
Where
(
p
=>
(
this
.
walletManager
as
IDeStreamWalletManager
).
GetOwnAddresses
(
context
.
AccountReference
)
.
Contains
(
p
.
ScriptPubKey
.
GetDestinationAddress
(
this
.
network
).
ToString
())
&&
context
.
UnspentOutputs
.
All
(
q
=>
p
.
ScriptPubKey
!=
q
.
Address
.
ScriptPubKey
));
foreach
(
var
ownAddress
in
transfersToSelf
)
{
var
ownHdAddress
=
this
.
walletManager
.
GetAccounts
(
context
.
AccountReference
.
WalletName
)
.
Single
(
q
=>
q
.
Name
==
context
.
AccountReference
.
AccountName
).
GetCombinedAddresses
()
.
Single
(
p
=>
string
.
Equals
(
ownAddress
.
ScriptPubKey
.
GetDestinationAddress
(
this
.
network
).
ToString
(),
p
.
Address
));
var
ownAddressPrivateKey
=
seedExtKey
.
Derive
(
new
KeyPath
(
ownHdAddress
.
HdPath
)).
GetWif
(
wallet
.
Network
);
signingKeys
.
Add
(
ownAddressPrivateKey
);
}
// signingKeys.UnionWith(context.Recipients.Where(p =>
// (this.walletManager as IDeStreamWalletManager).GetOwnAddresses(context.AccountReference)
// .Contains(p.ScriptPubKey.GetDestinationAddress(this.network).ToString()) &&
// context.UnspentOutputs.All(q => p.ScriptPubKey != q.Address.ScriptPubKey)).Select(r =>
// seedExtKey.Derive(new KeyPath(this.walletManager.GetAccounts(context.AccountReference.WalletName)
// .Single(q => q.Name == context.AccountReference.AccountName).GetCombinedAddresses()
// .Single(p =>
// string.Equals(r.ScriptPubKey.GetDestinationAddress(this.network).ToString(), p.Address))
// .HdPath)).GetWif(wallet.Network)));
context
.
TransactionBuilder
.
AddKeys
(
signingKeys
.
ToArray
());
}
...
...
Sources/Stratis.Bitcoin.Features.Wallet/Interfaces/IDeStreamWalletManager.cs
View file @
73573c27
namespace
Stratis.Bitcoin.Features.Wallet.Interfaces
using
System.Collections.Generic
;
namespace
Stratis.Bitcoin.Features.Wallet.Interfaces
{
public
interface
IDeStreamWalletManager
:
IWalletManager
{
...
...
@@ -8,5 +10,7 @@
void
ProcessGenesisBlock
();
HdAddress
CreateAddress
(
WalletAccountReference
accountReference
);
IEnumerable
<
string
>
GetOwnAddresses
(
WalletAccountReference
accountReference
);
}
}
\ No newline at end of file
Sources/Stratis.Bitcoin.Networks/DeStreamMain.cs
View file @
73573c27
...
...
@@ -164,7 +164,7 @@ namespace Stratis.Bitcoin.Networks
new
DNSSeedData
(
"seed2.destream.io"
,
"seed2.destream.io"
)
};
string
[]
seedNodes
=
{
"
13.68.198.162"
,
"13.70.18.10
4"
};
string
[]
seedNodes
=
{
"
46.101.9.205"
,
"178.62.251.178"
,
"134.209.225.24
4"
};
this
.
SeedNodes
=
this
.
ConvertToNetworkAddresses
(
seedNodes
,
this
.
DefaultPort
).
ToList
();
...
...
app.tpl.yml
View file @
73573c27
---
apiVersion
:
networking.k8s.io/v1
kind
:
NetworkPolicy
metadata
:
name
:
node1-deny-traffic-except-platform
namespace
:
test
spec
:
podSelector
:
matchLabels
:
app
:
node1
policyTypes
:
-
Ingress
-
Egress
ingress
:
-
from
:
-
ipBlock
:
cidr
:
10.233.0.0/17
-
from
:
-
ipBlock
:
cidr
:
151.101.112.249/32
egress
:
-
to
:
-
ipBlock
:
cidr
:
10.233.0.0/17
-
to
:
-
ipBlock
:
cidr
:
151.101.112.249/32
---
apiVersion
:
networking.k8s.io/v1
kind
:
NetworkPolicy
metadata
:
name
:
node2-deny-traffic-except-platform
namespace
:
test
spec
:
podSelector
:
matchLabels
:
app
:
node2
policyTypes
:
-
Ingress
-
Egress
ingress
:
-
from
:
-
ipBlock
:
cidr
:
10.233.0.0/17
-
from
:
-
ipBlock
:
cidr
:
151.101.112.249/32
egress
:
-
to
:
-
ipBlock
:
cidr
:
10.233.0.0/17
-
to
:
-
ipBlock
:
cidr
:
151.101.112.249/32
---
apiVersion
:
networking.k8s.io/v1
kind
:
NetworkPolicy
metadata
:
name
:
node3-deny-traffic-except-platform
namespace
:
test
spec
:
podSelector
:
matchLabels
:
app
:
node3
policyTypes
:
-
Ingress
-
Egress
ingress
:
-
from
:
-
ipBlock
:
cidr
:
10.233.0.0/17
-
from
:
-
ipBlock
:
cidr
:
151.101.112.249/32
egress
:
-
to
:
-
ipBlock
:
cidr
:
10.233.0.0/17
-
to
:
-
ipBlock
:
cidr
:
151.101.112.249/32
---
kind
:
PersistentVolume
apiVersion
:
v1
metadata
:
name
:
pv-node1
namespace
:
test
labels
:
type
:
local
spec
:
storageClassName
:
hostssd
capacity
:
storage
:
10Gi
accessModes
:
-
ReadWriteOnce
hostPath
:
path
:
"
/mnt/node1"
---
kind
:
PersistentVolumeClaim
apiVersion
:
v1
metadata
:
name
:
pv-node1-claim
namespace
:
test
spec
:
storageClassName
:
hostssd
accessModes
:
-
ReadWriteOnce
resources
:
requests
:
storage
:
10Gi
---
kind
:
PersistentVolume
apiVersion
:
v1
metadata
:
name
:
pv-node2
namespace
:
test
labels
:
type
:
local
spec
:
storageClassName
:
hostssd
capacity
:
storage
:
10Gi
accessModes
:
-
ReadWriteOnce
hostPath
:
path
:
"
/mnt/node2"
---
kind
:
PersistentVolumeClaim
apiVersion
:
v1
metadata
:
name
:
pv-node2-claim
namespace
:
test
spec
:
storageClassName
:
hostssd
accessModes
:
-
ReadWriteOnce
resources
:
requests
:
storage
:
10Gi
---
kind
:
PersistentVolume
apiVersion
:
v1
metadata
:
name
:
pv-node3
namespace
:
test
labels
:
type
:
local
spec
:
storageClassName
:
hostssd
capacity
:
storage
:
10Gi
accessModes
:
-
ReadWriteOnce
hostPath
:
path
:
"
/mnt/node3"
---
kind
:
PersistentVolumeClaim
apiVersion
:
v1
metadata
:
name
:
pv-node3-claim
namespace
:
test
spec
:
storageClassName
:
hostssd
accessModes
:
-
ReadWriteOnce
resources
:
requests
:
storage
:
10Gi
---
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
node1
namespace
:
test
labels
:
app
:
node1
spec
:
ports
:
-
name
:
node1-api
port
:
56833
targetPort
:
node1-api
selector
:
app
:
node1
---
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
node1
labels
:
app
:
node1
namespace
:
test
spec
:
replicas
:
1
revisionHistoryLimit
:
2
strategy
:
type
:
RollingUpdate
rollingUpdate
:
maxSurge
:
1
maxUnavailable
:
0
selector
:
matchLabels
:
app
:
node1
template
:
metadata
:
labels
:
app
:
node1
spec
:
containers
:
-
name
:
node1
image
:
_IMAGE_NAME_:_VERSION_
command
:
[
"
dotnet"
]
args
:
[
"
DeStream.DeStreamD.dll"
,
"
-addnode=node2"
,
"
-addnode=node3"
,
"
IpRangeFiltering=false"
]
ports
:
-
name
:
node1-api
containerPort
:
56833
volumeMounts
:
-
name
:
pv-node1
mountPath
:
"
/root/.destreamnode"
nodeName
:
node1
imagePullSecrets
:
-
name
:
registrypullsecret
volumes
:
-
name
:
pv-node1
persistentVolumeClaim
:
claimName
:
pv-node1-claim
---
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
node2
namespace
:
test
labels
:
app
:
node2
spec
:
ports
:
-
name
:
node2-api
port
:
56833
targetPort
:
node2-api
selector
:
app
:
node2
---
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
node2
labels
:
app
:
node2
namespace
:
test
spec
:
replicas
:
1
revisionHistoryLimit
:
2
strategy
:
type
:
RollingUpdate
rollingUpdate
:
maxSurge
:
1
maxUnavailable
:
0
selector
:
matchLabels
:
app
:
node2
template
:
metadata
:
labels
:
app
:
node2
spec
:
containers
:
-
name
:
node2
image
:
_IMAGE_NAME_:_VERSION_
command
:
[
"
dotnet"
]
args
:
[
"
DeStream.DeStreamD.dll"
,
"
-addnode=node1"
,
"
-addnode=node3"
,
"
IpRangeFiltering=false"
]
ports
:
-
name
:
node2-api
containerPort
:
56833
volumeMounts
:
-
name
:
pv-node2
mountPath
:
"
/root/.destreamnode"
nodeName
:
node2
imagePullSecrets
:
-
name
:
registrypullsecret
volumes
:
-
name
:
pv-node2
persistentVolumeClaim
:
claimName
:
pv-node2-claim
---
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
node3
namespace
:
test
labels
:
app
:
node3
spec
:
ports
:
-
name
:
node3-api
port
:
56833
targetPort
:
node3-api
selector
:
app
:
node3
---
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
node
name
:
node
3
labels
:
app
:
node
app
:
node
3
namespace
:
test
spec
:
replicas
:
3
replicas
:
1
revisionHistoryLimit
:
2
strategy
:
type
:
Recreate
type
:
RollingUpdate
rollingUpdate
:
maxSurge
:
1
maxUnavailable
:
0
selector
:
matchLabels
:
app
:
node
app
:
node
3
template
:
metadata
:
labels
:
app
:
node
app
:
node
3
spec
:
containers
:
-
name
:
node
-
name
:
node
3
image
:
_IMAGE_NAME_:_VERSION_
command
:
[
"
dotnet"
]
args
:
[
"
DeStream.DeStreamD.dll"
]
args
:
[
"
DeStream.DeStreamD.dll"
,
"
-addnode=node1"
,
"
-addnode=node2"
,
"
IpRangeFiltering=false"
]
ports
:
-
name
:
node-api
-
name
:
node
3
-api
containerPort
:
56833
-
name
:
node-svc
containerPort
:
56864
volumeMounts
:
-
name
:
pv-node
-test
-
name
:
pv-node
3
mountPath
:
"
/root/.destreamnode"
nodeName
:
node3
imagePullSecrets
:
-
name
:
registrypullsecret
volumes
:
-
name
:
pv-node
-test
-
name
:
pv-node
3
persistentVolumeClaim
:
claimName
:
pv-node-test-claim
\ No newline at end of file
claimName
:
pv-node3-claim
\ No newline at end of file
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