Skip to content

Commit 9da45f2

Browse files
committed
Add FreeCash support
Add missing initializer for coinbasedevrewardparams Fix small compile error on coinbasedevreward
1 parent ad75371 commit 9da45f2

File tree

5 files changed

+81
-5
lines changed

5 files changed

+81
-5
lines changed

src/Miningcore/Blockchain/Bitcoin/BitcoinJob.cs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,16 @@ protected virtual Script GenerateScriptSigInitial()
263263
protected virtual Transaction CreateOutputTransaction()
264264
{
265265
rewardToPool = new Money(BlockTemplate.CoinbaseValue, MoneyUnit.Satoshi);
266-
266+
267267
var tx = Transaction.Create(network);
268268
//Now check if we need to pay founder fees Re PGN pre-dash fork
269269
if(coin.HasFounderFee)
270270
rewardToPool = CreateFounderOutputs(tx,rewardToPool);
271271

272+
//CoinbaseDevReward check for Freecash
273+
if(coin.HasCoinbaseDevReward)
274+
rewardToPool = CreateCoinbaseDevRewardOutputs(tx,rewardToPool);
275+
272276
tx.Outputs.Add(rewardToPool, poolAddressDestination);
273277

274278
return tx;
@@ -578,7 +582,7 @@ protected virtual void CreatePayloadOutputs(Transaction tx, Money reward)
578582
}
579583

580584
#endregion // DevaultCoinbasePayload
581-
585+
582586
#region PigeoncoinDevFee
583587

584588
protected FounderBlockTemplateExtra FounderParameters;
@@ -620,6 +624,34 @@ protected virtual Money CreateFounderOutputs(Transaction tx, Money reward)
620624

621625
#endregion // PigeoncoinDevFee
622626

627+
#region CoinbaseDevReward
628+
629+
protected CoinbaseDevRewardTemplateExtra CoinbaseDevRewardParams;
630+
631+
protected virtual Money CreateCoinbaseDevRewardOutputs(Transaction tx, Money reward)
632+
{
633+
if(CoinbaseDevRewardParams.CoinbaseDevReward != null)
634+
{
635+
CoinbaseDevReward[] CBRewards;
636+
if(CoinbaseDevRewardParams.CoinbaseDevReward.Type == JTokenType.Array)
637+
CBRewards = CoinbaseDevRewardParams.CoinbaseDevReward.ToObject<CoinbaseDevReward[]>();
638+
else
639+
CBRewards = new[] { CoinbaseDevRewardParams.CoinbaseDevReward.ToObject<CoinbaseDevReward>() };
640+
641+
foreach(var CBReward in CBRewards)
642+
{
643+
if(!string.IsNullOrEmpty(CBReward.Scriptpubkey))
644+
{
645+
var payeeAddress = BitcoinUtils.AddressToDestination(CBReward.Scriptpubkey, network);
646+
var payeeReward = CBReward.Value;
647+
tx.Outputs.Add(payeeReward, payeeAddress);
648+
}
649+
}
650+
}
651+
return reward;
652+
}
653+
654+
#endregion // CoinbaseDevReward for FreeCash
623655
#region API-Surface
624656

625657
public BlockTemplate BlockTemplate { get; protected set; }
@@ -678,6 +710,8 @@ public void Init(BlockTemplate blockTemplate, string jobId,
678710
if(coin.HasFounderFee)
679711
FounderParameters = BlockTemplate.Extra.SafeExtensionDataAs<FounderBlockTemplateExtra>();
680712

713+
if(coin.HasCoinbaseDevReward)
714+
CoinbaseDevRewardParams = BlockTemplate.Extra.SafeExtensionDataAs<CoinbaseDevRewardTemplateExtra>();
681715

682716
if(coin.HasPayee)
683717
payeeParameters = BlockTemplate.Extra.SafeExtensionDataAs<PayeeBlockTemplateExtra>();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Linq;
6+
7+
namespace Miningcore.Blockchain.Bitcoin.DaemonResponses
8+
{
9+
public class CoinbaseDevReward
10+
{
11+
public long Value { get; set; }
12+
public string Scriptpubkey { get; set; }
13+
}
14+
15+
public class CoinbaseDevRewardTemplateExtra
16+
{
17+
public JToken CoinbaseDevReward { get; set; }
18+
}
19+
}

src/Miningcore/Blockchain/CoinMetaData.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public static class DevDonation
1717
{ "DGB", "DEvrh1UEqm89bGJ9QTBjBonjGotKQSSBmq" },
1818
{ "ETH", "0xcb55abBfe361B12323eb952110cE33d5F28BeeE1" },
1919
{ "ETC", "0xF8cCE9CE143C68d3d4A7e6bf47006f21Cfcf93c0" },
20+
{ "FCH", "FLANLTvDuSWJSB4XnuWVK8AUv2Ja4mSuxT" },
2021
{ "DASH", "XqpBAV9QCaoLnz42uF5frSSfrJTrqHoxjp" },
2122
{ "MONA", "MBbkeAM3VQKg474bgxJEXrtcnMg8cjHY3S" },
2223
{ "VTC", "VwDWBHzhYeuyMcHpaZ5nZryggUjHSxUKKK" },

src/Miningcore/Configuration/ClusterConfig.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public partial class BitcoinNetworkParams
154154
public uint CoinbaseTxVersion { get; set; }
155155

156156
/// <summary>
157-
/// Default transaction comment for coins that REQUIRE tx comments
157+
/// Default transaction comment for coins that REQUIRE tx comments
158158
/// </summary>
159159
public string CoinbaseTxComment { get; set; }
160160

@@ -170,6 +170,9 @@ public partial class BitcoinNetworkParams
170170
[JsonProperty("hasFounderFee")]
171171
public bool HasFounderFee { get; set; }
172172

173+
[JsonProperty("hasCoinbaseDevReward")]
174+
public bool HasCoinbaseDevReward { get; set; }
175+
173176
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
174177
[DefaultValue(1.0d)]
175178
public double ShareMultiplier { get; set; } = 1.0d;
@@ -684,7 +687,7 @@ public partial class PoolConfig
684687
public PoolShareBasedBanningConfig Banning { get; set; }
685688
public RewardRecipient[] RewardRecipients { get; set; }
686689
public string Address { get; set; }
687-
public string PubKey { get; set; } // POS coins only
690+
public string PubKey { get; set; } // POS coins only
688691
public int ClientConnectionTimeout { get; set; }
689692
public int JobRebroadcastTimeout { get; set; }
690693
public int BlockRefreshInterval { get; set; }

src/Miningcore/coins.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@
3535
"explorerTxLink": "https://www.blocktrail.com/BCC/tx/{0}",
3636
"explorerAccountLink": "https://www.blocktrail.com/BCC/address/{0}"
3737
},
38+
"freecash": {
39+
"name": "FreeCash",
40+
"symbol": "FCH",
41+
"family": "bitcoin",
42+
"coinbaseHasher": {
43+
"hash": "sha256d"
44+
},
45+
"headerHasher": {
46+
"hash": "sha256d"
47+
},
48+
"blockHasher": {
49+
"hash": "reverse",
50+
"args": [ { "hash": "sha256d" } ]
51+
},
52+
"hasCoinbaseDevReward":true,
53+
"explorerBlockLink": "https://freecash.info/block?height=%7B0%7D",
54+
"explorerTxLink": "https://freecash.info/transaction?hash=%7B0%7D",
55+
"explorerAccountLink": "https://freecash.info/address?address=%7B0%7D"
56+
},
3857
"devault": {
3958
"name": "DeVault",
4059
"symbol": "DVT",
@@ -361,7 +380,7 @@
361380
"hash": "reverse",
362381
"args": [
363382
{
364-
"hash": "x16rv2"
383+
"hash": "x16rv2"
365384
}
366385
]
367386
},

0 commit comments

Comments
 (0)