Skip to content

Commit

Permalink
Add Support DevFee
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaolin1579 committed Jul 19, 2024
1 parent 031a2d4 commit cbfa0a8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/Miningcore/Blockchain/Bitcoin/BitcoinJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,12 @@ protected virtual Money CreateMasternodeOutputs(Transaction tx, Money reward)
{
foreach(var masterNode in masternodes)
{
if(!string.IsNullOrEmpty(masterNode.Payee))
if(!string.IsNullOrEmpty(masterNode.Script))
{
var payeeDestination = BitcoinUtils.AddressToDestination(masterNode.Payee, network);
Script payeeAddress = new (masterNode.Script.HexToByteArray());
var payeeReward = masterNode.Amount;

tx.Outputs.Add(payeeReward, payeeDestination);
tx.Outputs.Add(payeeReward, payeeAddress);
reward -= payeeReward;
}
}
Expand Down Expand Up @@ -525,9 +525,9 @@ protected virtual Money CreateFounderOutputs(Transaction tx, Money reward)
{
foreach(var Founder in founders)
{
if(!string.IsNullOrEmpty(Founder.Payee))
if(!string.IsNullOrEmpty(Founder.Script))
{
var payeeAddress = BitcoinUtils.AddressToDestination(Founder.Payee, network);
Script payeeAddress = new (Founder.Script.HexToByteArray());
var payeeReward = Founder.Amount;

tx.Outputs.Add(payeeReward, payeeAddress);
Expand Down Expand Up @@ -708,15 +708,24 @@ public void Init(BlockTemplate blockTemplate, string jobId,
payeeParameters = BlockTemplate.Extra.SafeExtensionDataAs<PayeeBlockTemplateExtra>();

if (coin.HasFounderFee)
{
founderParameters = BlockTemplate.Extra.SafeExtensionDataAs<FounderBlockTemplateExtra>();

if(coin.HasDevFee)
{
if(founderParameters.Extra?.ContainsKey("devfee") == true)
{
founderParameters.Founder = JToken.FromObject(founderParameters.Extra["devfee"]);
}
}
}
if (coin.HasMinerFund)
minerFundParameters = BlockTemplate.Extra.SafeExtensionDataAs<MinerFundTemplateExtra>("coinbasetxn", "minerfund");

if(coin.HasCoinbaseDevReward)
if(coin.HasCoinbaseDevReward)
CoinbaseDevRewardParams = BlockTemplate.Extra.SafeExtensionDataAs<CoinbaseDevRewardTemplateExtra>();

if(coin.HasFoundation)
if(coin.HasFoundation)
foundationParameters = BlockTemplate.Extra.SafeExtensionDataAs<FoundationBlockTemplateExtra>();

this.coinbaseHasher = coinbaseHasher;
Expand Down
3 changes: 3 additions & 0 deletions src/Miningcore/Blockchain/Bitcoin/DaemonResponses/Founder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ public class FounderBlockTemplateExtra

[JsonProperty("founder_payments_started")]
public bool FounderPaymentsStarted { get; set; }

[JsonExtensionData]
public IDictionary<string, object> Extra { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/Miningcore/Configuration/ClusterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ public class BitcoinNetworkParams
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool HasFounderFee { get; set; }

[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool HasDevFee { get; set; }

[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool HasMinerFund { get; set; }

Expand Down

0 comments on commit cbfa0a8

Please sign in to comment.