Bitcoin Forum
May 11, 2024, 01:07:50 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: MonoBitcoind, a Mono/C# Wrapper for the Bitcoind calls  (Read 1602 times)
CoinBeyond (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 0


View Profile
April 23, 2014, 03:46:32 AM
 #1

Hey Community,

I needed a way to automate raw transactions with multisig accounts, and I was used to using bitcoind, so I created a few functions in C# to make doing this a lot easier.  Now I don't have to touch the outgoing JSON-RPC calls, so no more stupid syntax errors for me.

In order to prevent other future headaches, I started doing this for a bunch of the bitcoind commands.  

Then thinking it would be cool to create a library of all the bitcoind commands so other bitcoin automation noobs wouldn't have to suffer like I did, I powered through and implemented simple C# methods for every command (except 3: getblocktemplate, getwork, and submitblock; I feel like I need to learn more about these first).

Here it is: https://github.com/nrjudson/MonoBitcoind

So it's super easy to pick up, I gave examples for every call too.  And none of the names of the bitcoind functions have changed (for better or for worse).

Because all of the bitcoind commands are in a single class, you only have to Ctrl+f one file to find what you're looking for.  You also only need to copy this one file and the json.NET library to have a full interface to bitcoind.

Enjoy~

Noah
1715389670
Hero Member
*
Offline Offline

Posts: 1715389670

View Profile Personal Message (Offline)

Ignore
1715389670
Reply with quote  #2

1715389670
Report to moderator
"Bitcoin: the cutting edge of begging technology." -- Giraffe.BTC
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715389670
Hero Member
*
Offline Offline

Posts: 1715389670

View Profile Personal Message (Offline)

Ignore
1715389670
Reply with quote  #2

1715389670
Report to moderator
doof
Hero Member
*****
Offline Offline

Activity: 765
Merit: 503


View Profile WWW
April 23, 2014, 09:13:15 AM
 #2

There is a great c# biconid wrapper on github already called bitcoinrpcsharp.  You might want to look at using some of that code.
mcaizgk2
Member
**
Offline Offline

Activity: 66
Merit: 10


View Profile
April 23, 2014, 11:17:07 AM
 #3

It's good to see more C# developers getting involved in bitcoin development.

Before deciding to create your own wrapper though, which is not a trivial task, I would suggest you take a look to what is already out there, so you might want to take a look at BitcoinLib:

https://github.com/GeorgeKimionis/BitcoinLib

Some of BitcoinLib's features:

- Fully compatible and up-to-date with Bitcoin 0.9.1 RPC API.
- Design-by-contract, service-oriented architecture.
- Strongly-typed structures for complex RPC requests and responses.
- Implicit JSON casting for all RPC messages.
- Extended methods for every-day scenarios where the built-in methods fall short.
- Exposure of all RPC API's functionality as well as the extended methods through a single interface.
- Fallback mechanism for timed-out RPC requests.
- Custom RPC exceptions.
- Supports all Bitcoin clones.
- Can operate on unlimited daemons with a single library reference.
- Litecoin integration included.
- Each coin instance can be fully parametrized at run-time and implement its own constants.
- Console and web test clients out of the box with demo methods implemented in them.
- Testnet ready.
- Fully configurable.


archit
Full Member
***
Offline Offline

Activity: 159
Merit: 100


View Profile
April 23, 2014, 11:24:21 AM
 #4

Also maybe have  a look at this. It's some unfinished code by me but can show you how to use getblocktemplate in C#.

https://github.com/archit120/xptProxy/blob/master/XptProxy/Program.cs#L295
CoinBeyond (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 0


View Profile
April 24, 2014, 12:57:58 AM
 #5

Thanks guys,

Yeah!  I actually found BitcoinLib and bitcoinrpcsharp during development, and then decided to finish anyway.  I made sure to give them, BitSharp, and Bitcoin.NET props in the README's summary section. 

There's a lot of great stuff in those libraries, yet there's also a lot that we might never need.  CoinBeyond doesn't plan on using wallets or the accounts system.  We also can't risk having customers' private keys used in any way that we're not intimately knowledgeable about.  It's going to take some time and effort to look deep into each of the open source projects for our requirements and knowing exactly the way private keys are handled, so I'm not sure whether to do that or make our own, or both.  Are any of these other projects regarded as extremely secure?

It's possible that we'll use MonoBitcoind or one of the other projects in our backend where we process the bitcoin part of card transactions.  Regarding libraries that are under the GPL license, does that mean we'll need to open source GPL-license anything that uses a GPL-licensed library if and only if we distribute something that comes packaged with some GPL-licensed code?  In other words, is it fine if we use GPL-licensed code in closed-source code on the backend?

Thanks u/archit, that helps a lot!
cwil
Sr. Member
****
Offline Offline

Activity: 285
Merit: 259


View Profile
April 24, 2014, 02:19:37 AM
 #6

Typically with GPL and compatibles, if you don't distribute, you don't have to provide source.  In contrast, MIT/BSD-like licenses typically don't require you to distribute source under any circumstance.  I'd recommend consulting a lawyer to avoid any potential liability.
mcaizgk2
Member
**
Offline Offline

Activity: 66
Merit: 10


View Profile
April 24, 2014, 02:36:23 AM
 #7

BitcoinLib is battle tested and there are already some commercial solutions running on top of it. It doesn't interact with private keys (unless explicitly asked to) and is absolutely safe to use. You can test its functionality easily with the bundled test clients. Oh, and thanks for the props!
CoinBeyond (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 0


View Profile
April 25, 2014, 12:56:40 AM
 #8

I'm honored to be in a community with such helpful people, thanks for being so awesome.

mcaizgk2, are you George Kimionis?!  Congrats on your open source project!  It must feel pretty good knowing you made something for the world to have and use. 

You've all convinced me to take much more time evaluating the open source options available.  I'm looking to do some multisignature and hierarchical deterministic work with keys.  I may end up forking your code and building it off of that.
Nicolas Dorier
Hero Member
*****
Offline Offline

Activity: 714
Merit: 621


View Profile
April 25, 2014, 10:46:23 PM
 #9

I implemented the BIP 32 (Hierarchical deterministic) part in C# already. It is on nuget : Install-Package NBitcoin.
There is unit tests to see how to use it. (These unit tests are the same as the on in Bitcoin core)
Take a look at https://github.com/NicolasDorier/NBitcoin
I will not implement the JSON RPC part, but will implement the raw protocol part.

Bitcoin address 15sYbVpRh6dyWycZMwPdxJWD4xbfxReeHe
mcaizgk2
Member
**
Offline Offline

Activity: 66
Merit: 10


View Profile
April 26, 2014, 03:02:21 AM
 #10

mcaizgk2, are you George Kimionis?!  Congrats on your open source project!  It must feel pretty good knowing you made something for the world to have and use. 

You've all convinced me to take much more time evaluating the open source options available.  I'm looking to do some multisignature and hierarchical deterministic work with keys.  I may end up forking your code and building it off of that.

Thanks Noah, I appreciate it, although many great developers, to whom I am deeply indebted, laid the foundation before me and I have sought to give credit to whom credit is due but I'm sure I've skipped over some.

Contributing to such a great concept is the least we can do and I'm surely glad many have found BitcoinLib of some use.

You should definitely take some time to see what is available and whether one of these libraries fits your needs before deciding to build your own.
CoinBeyond (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 0


View Profile
April 29, 2014, 04:56:16 AM
 #11

I implemented the BIP 32 (Hierarchical deterministic) part in C# already. It is on nuget : Install-Package NBitcoin.
There is unit tests to see how to use it. (These unit tests are the same as the on in Bitcoin core)
Take a look at https://github.com/NicolasDorier/NBitcoin
I will not implement the JSON RPC part, but will implement the raw protocol part.

You rock Nicolas.  Seriously, your code is helping me make so much more sense of the implementation.

By the way, you should add a link to your code in the Implementations section of bip-0032.  https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#implementations
I thought there was currently no C# implementation before.

And way to go porting the entire bitcoin core code to C#!  How complete would you say it is?
CoinBeyond (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 0


View Profile
April 29, 2014, 05:28:56 AM
 #12

I implemented the BIP 32 (Hierarchical deterministic) part in C# already. It is on nuget : Install-Package NBitcoin.
There is unit tests to see how to use it. (These unit tests are the same as the on in Bitcoin core)
Take a look at https://github.com/NicolasDorier/NBitcoin
I will not implement the JSON RPC part, but will implement the raw protocol part.

Cheers, 7f522408bd170dbc236a27dfca036f9bdc7248f09d3264e3c92ba20f94529fdf
Nicolas Dorier
Hero Member
*****
Offline Offline

Activity: 714
Merit: 621


View Profile
April 29, 2014, 01:37:34 PM
 #13

How complete would you say it is?

Depending on what you want to do, NBitcoin is complete enough. I expect having a full Node server implemented by the end of the week. (I am coding almost full time on it)
NBitcoin is, I think, the most complete implementation in all languages.

Well, the fun part is the more I dig in bitcoin, the more there is to code.
But I'm coding it every day and eventually will keep up.

Now it is slower, because unit tests are not helping me anymore. (Most of the unit tests, I already ported it)

I coded a Wallet that keep history for accounting purpose, but do not support other wallet format right now. With my wallet, a clerk can see if the wallet was impacted by a fork by example).
Right now, I am coding a full node (NodeServer). I implemented the node discovery part yestersday. I will make the code to keep up from the block chain today.

You can already serialize/deserialize almost all messages of the protocol as well as sending and receive them. (take a look at the test CanDoVersionHandshake, the Node class permit you to send messages to another node)

If you use the NodeServer, use the .NET Trace Source called "NBitcoin.NodeServer" (look at Tests/App.config). It generates an XML log file you can open with Microsoft Service Trace Viewer that group all the traces by node, so you can easily filter, and see how things work)

Thanks a lot for your bitcoin, appreciate it Smiley))

Bitcoin address 15sYbVpRh6dyWycZMwPdxJWD4xbfxReeHe
MithrilMan
Hero Member
*****
Offline Offline

Activity: 554
Merit: 502

Developer!


View Profile WWW
April 30, 2014, 06:01:21 PM
 #14

How complete would you say it is?

Depending on what you want to do, NBitcoin is complete enough. I expect having a full Node server implemented by the end of the week. (I am coding almost full time on it)
NBitcoin is, I think, the most complete implementation in all languages.

Well, the fun part is the more I dig in bitcoin, the more there is to code.
But I'm coding it every day and eventually will keep up.

Now it is slower, because unit tests are not helping me anymore. (Most of the unit tests, I already ported it)

I coded a Wallet that keep history for accounting purpose, but do not support other wallet format right now. With my wallet, a clerk can see if the wallet was impacted by a fork by example).
Right now, I am coding a full node (NodeServer). I implemented the node discovery part yestersday. I will make the code to keep up from the block chain today.

You can already serialize/deserialize almost all messages of the protocol as well as sending and receive them. (take a look at the test CanDoVersionHandshake, the Node class permit you to send messages to another node)

If you use the NodeServer, use the .NET Trace Source called "NBitcoin.NodeServer" (look at Tests/App.config). It generates an XML log file you can open with Microsoft Service Trace Viewer that group all the traces by node, so you can easily filter, and see how things work)

Thanks a lot for your bitcoin, appreciate it Smiley))


hey Nicolas nice project, I'll dive into your implementation when I find time!
I've implemented a .Net client for Huntercoin in .Net, that use RPC calls (but it's closed sourced because it will be a service and bound to accounts, etc..) and i'd like to see your implementation because i could try to use it as a base to port huntercoin in C# maybe, even if huntercoin is based on Namecoin
Your codebase could be even useful as a base for a .Net altcoin

Talking about internals, i'm still new to cryptocoin, so I don't know if current bitcoin implementation could handle game data (and validation of that data) into blockchain
From what have you seen, is it possible to store data into a transation, that could be validated by peers and reject that transation if it violates the "game rules"?

Huntercoin: Mithril Edition - Alternative client for Huntercoin - (Discontinued)
HUC: HMSCYGYJ5wo9FiniVU4pXWGUu8E8PSmoHE  - BTC: 1DKLf1QKAZ5njucq37pZhMRG67qXDP3vPC
rant to people who pretend things for free
Nicolas Dorier
Hero Member
*****
Offline Offline

Activity: 714
Merit: 621


View Profile
April 30, 2014, 11:47:17 PM
 #15

you can include 40 bytes of data per transaction. (It is a special output script called in the code "TxNull")
I'm not sure Bitcoin is the easiest,usefull and cheapful way to store game data though.

I am not doing an JSON RPC client right know, I am directly talking to bitcoin with the RAW protocol.
You can create, and send such transaction with NBitcoin right know.

You can see tests with the "NodeServer" unit test trait, they show how to send messages to nodes.

(If you pulled my code, pulled it often, because I'm committing a lot these days)

Bitcoin address 15sYbVpRh6dyWycZMwPdxJWD4xbfxReeHe
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!