Skip to content

Remove Blockcore.Core dependency, migrate to pure NBitcoin#905

Open
DavidGershony wants to merge 2 commits into
mainfrom
remove-blockcore-dependency
Open

Remove Blockcore.Core dependency, migrate to pure NBitcoin#905
DavidGershony wants to merge 2 commits into
mainfrom
remove-blockcore-dependency

Conversation

@DavidGershony

Copy link
Copy Markdown
Collaborator

Summary

  • Remove Blockcore.Core NuGet package from all projects, replacing all Blockcore.NBitcoin.* and Blockcore.Consensus.* types with their NBitcoin.* equivalents
  • Introduce AngorNetwork wrapper class (src/shared/Angor.Shared/Networks/AngorNetwork.cs) to replace Blockcore's custom network classes
  • Set TransactionBuilder.ShuffleOutputs = false and DustPrevention = false in all production BuildTransaction() paths (NBitcoin defaults differ from Blockcore's fork)
  • Retain Blockcore.Nostr.Client package (provides Nostr.Client.* namespace, unrelated to Bitcoin)

Key Changes

Infrastructure:

  • New AngorNetwork class wraps NBitcoin.Network with Angor-specific metadata (CoinType, IsMainnet, Name)
  • Deleted 6 custom network classes (BitcoinMain, BitcoinSignet, BitcoinTest, BitcoinTest4, Angornet, LiquidMain)
  • Deleted NetworkMapper.cs — replaced by AngorNetwork.BitcoinNetwork property and implicit conversion

Type Migrations:

  • Blockcore.NBitcoin.*NBitcoin.* (1:1 mapping)
  • Blockcore.Consensus.TransactionInfo.*NBitcoin.*
  • Blockcore.Consensus.ScriptInfo.*NBitcoin.*
  • network.Consensus.CoinTypenetwork.CoinType
  • Hashes.Hash256Hashes.DoubleSHA256
  • tx.ToHex(ConsensusFactory)tx.ToHex()

Critical behavioral differences handled:

  • TransactionBuilder.ShuffleOutputs = false — Blockcore didn't shuffle; NBitcoin does by default
  • TransactionBuilder.DustPrevention = false — Angor protocol has sub-dust OP_RETURN outputs
  • Script.ToOps() returns IEnumerable<Op> in NBitcoin (vs IList<Op> in Blockcore) — added .ToList() where indexing is needed

UAT automation improvement:

  • Deploy polling now detects errors early and returns descriptive messages instead of waiting the full 2-minute timeout

Testing

Suite Result
Angor.Shared.Tests 146/146 passed
Angor.Sdk.Tests 348/348 passed
UAT CreateProjectTest Passed (1m18s)
Avalonia.sln build Clean (iOS workload excluded)
App.sln build Clean (iOS workload excluded)
WebApp.sln build Clean

Not in scope

  • NBitcoin version upgrade (7.0.46 → 10.0.7) — deferred to separate PR

@DavidGershony DavidGershony requested a review from dangershony July 1, 2026 14:08
Comment thread .claude/settings.local.json Outdated
@@ -0,0 +1,19 @@
{
"permissions": {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want this pushed?

- Replace all Blockcore.NBitcoin.* and Blockcore.Consensus.* types with NBitcoin equivalents
- Introduce AngorNetwork wrapper class to replace custom Blockcore network classes
- Set TransactionBuilder.ShuffleOutputs=false and DustPrevention=false (NBitcoin defaults differ from Blockcore fork)
- Retain Blockcore.Nostr.Client (provides Nostr.Client.* namespace, unrelated to Bitcoin)
- Improve UAT deploy automation: detect errors early instead of waiting full TxTimeout
- Delete 6 custom network classes (BitcoinMain, BitcoinSignet, BitcoinTest, BitcoinTest4, Angornet, LiquidMain)
- Delete NetworkMapper.cs (replaced by AngorNetwork.BitcoinNetwork + implicit conversion)
// find the spending script for the current secret hash combination

var hashes = secrets.Select(secret => (Blockcore.NBitcoin.Crypto.Hashes.Hash256(secret.ToBytes()), new Script(secret.ToBytes()))).ToList();
var hashes = secrets.Select(secret => (Hashes.DoubleSHA256(secret.ToBytes()), new Script(secret.ToBytes()))).ToList();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this confirmed to be correct?

var taprootPubKey = new NBitcoin.TaprootPubKey(outputKeyBytes);
var address = taprootPubKey.GetAddress(NetworkMapper.Map(network));
var taprootPubKey = new TaprootPubKey(outputKeyBytes);
var address = taprootPubKey.GetAddress(network.BitcoinNetwork);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not clear to me, what is BitcoinNetwork? the current selected network?

…re-dependency

# Conflicts:
#	src/shared/Angor.Shared/Protocol/InvestorTransactionActions.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants