Class NeblioTransactionHelpers
Main Helper class for the Neblio Blockchain Transactions
Inheritance
Inherited Members
Namespace: VEDriversLite
Assembly: VEDriversLite.dll
Syntax
public static class NeblioTransactionHelpers
Fields
| Improve this Doc View SourceFromSatToMainRatio
Conversion ration for Neblio to convert from sat to 1 NEBL
Declaration
public const double FromSatToMainRatio = 100000000
Field Value
Type | Description |
---|---|
System.Double |
MinimumAmount
Minimum amount in Satoshi on Neblio Blockchain
Declaration
public static long MinimumAmount
Field Value
Type | Description |
---|---|
System.Int64 |
Network
NBitcoin Instance of Mainet Network of Neblio
Declaration
public static Network Network
Field Value
Type | Description |
---|---|
NBitcoin.Network |
Methods
| Improve this Doc View SourceCalcFee(Int32, Int32, String, Boolean)
This function will calculate the fee based of the known lenght of the intputs and the outputs If there is the OP_RETURN output it is considered as the customMessage. Please fill it for token transactions. Token transaction also will add just for sure one output to calculation of the size for the case there will be some tokens back to original address
Declaration
public static double CalcFee(int numOfInputs, int numOfOutputs, string customMessageInOPReturn, bool isTokenTransaction)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | numOfInputs | Number of input of the transaction "in" vector |
System.Int32 | numOfOutputs | Number of outpus of the transaction "out" vector |
System.String | customMessageInOPReturn | Custom message - "OP_RETURN" output |
System.Boolean | isTokenTransaction | Token transaction will add another output for getting back the tokens |
Returns
Type | Description |
---|---|
System.Double |
CreateOPRETURNScript(Byte[][])
Create OP_RETURN output ScriptPubKey from the input data. Data should not contain OP_RETURN byte. This byte is added in the function. PLease provide just the data which should be attached Data must be in not HEX form. The Op.GetPushOp function converts them during the loading.
Declaration
public static Script CreateOPRETURNScript(params byte[][] data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[][] | data |
Returns
Type | Description |
---|---|
NBitcoin.Script |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
DestroyNFTAsync(SendTokenTxData, ICollection<Utxos>, Double, Utxos, GetAddressInfoResponse, Double)
Destroy of the NFT. It merge the NFT with the minting lot 1VENFT + 10VENFT => 11 VENFT
Declaration
public static async Task<Transaction> DestroyNFTAsync(SendTokenTxData data, ICollection<Utxos> nutxos, double fee = 20000, Utxos mintingUtxo = null, GetAddressInfoResponse addinfo = null, double latestblockheight = 0)
Parameters
Type | Name | Description |
---|---|---|
SendTokenTxData | data | |
System.Collections.Generic.ICollection<Utxos> | nutxos | |
System.Double | fee | |
Utxos | mintingUtxo | |
GetAddressInfoResponse | addinfo | |
System.Double | latestblockheight |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NBitcoin.Transaction> |
Exceptions
Type | Condition |
---|---|
System.Exception |
GetAddressAndKey(EncryptionKey)
Function converts EncryptionKey (optionaly with password if it is not already loaded in ekey) and returns BitcoinAddress and BitcoinSecret classes from NBitcoin
Declaration
public static (BitcoinAddress, BitcoinSecret) GetAddressAndKey(EncryptionKey ekey)
Parameters
Type | Name | Description |
---|---|---|
EncryptionKey | ekey |
Returns
Type | Description |
---|---|
System.ValueTuple<NBitcoin.BitcoinAddress, NBitcoin.BitcoinSecret> |
GetAddressAndKey(EncryptionKey, String)
Function converts EncryptionKey (optionaly with password if it is not already loaded in ekey) and returns BitcoinAddress and BitcoinSecret classes from NBitcoin
Declaration
public static (BitcoinAddress, BitcoinSecret) GetAddressAndKey(EncryptionKey ekey, string password)
Parameters
Type | Name | Description |
---|---|---|
EncryptionKey | ekey | |
System.String | password |
Returns
Type | Description |
---|---|
System.ValueTuple<NBitcoin.BitcoinAddress, NBitcoin.BitcoinSecret> |
GetAddressFromPrivateKey(String)
Parse the Neblio address from the private key
Declaration
public static string GetAddressFromPrivateKey(string privatekey)
Parameters
Type | Name | Description |
---|---|---|
System.String | privatekey |
Returns
Type | Description |
---|---|
System.String |
GetAddressFromSignedScriptPubKey(String)
Declaration
public static BitcoinAddress GetAddressFromSignedScriptPubKey(string scriptAsm)
Parameters
Type | Name | Description |
---|---|---|
System.String | scriptAsm |
Returns
Type | Description |
---|---|
NBitcoin.BitcoinAddress |
GetAddressFromSignedScriptPubKey(ScriptSig)
Declaration
public static BitcoinAddress GetAddressFromSignedScriptPubKey(ScriptSig script)
Parameters
Type | Name | Description |
---|---|---|
ScriptSig | script |
Returns
Type | Description |
---|---|
NBitcoin.BitcoinAddress |
GetAddressStringFromSignedScriptPubKey(ScriptSig)
Declaration
public static string GetAddressStringFromSignedScriptPubKey(ScriptSig script)
Parameters
Type | Name | Description |
---|---|---|
ScriptSig | script |
Returns
Type | Description |
---|---|
System.String |
GetLastSentTransaction(String)
Find last send transaction by some address. This is usefull to obtain address public key from signature of input.
Declaration
public static async Task<Transaction> GetLastSentTransaction(string address)
Parameters
Type | Name | Description |
---|---|---|
System.String | address | Searched address |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NBitcoin.Transaction> | NBitcoin Transaction object |
GetMetaComprimed(IDictionary<String, String>)
Declaration
public static byte[] GetMetaComprimed(IDictionary<string, string> metadata)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<System.String, System.String> | metadata |
Returns
Type | Description |
---|---|
System.Byte[] |
GetNeblioTransactionObject(SendTxData, ICollection<Utxos>)
Function will send standard Neblio transaction
Declaration
public static Transaction GetNeblioTransactionObject(SendTxData data, ICollection<Utxos> nutxos)
Parameters
Type | Name | Description |
---|---|---|
SendTxData | data | Send data, please see SendTxData class for the details |
System.Collections.Generic.ICollection<Utxos> | nutxos | Optional input neblio utxo |
Returns
Type | Description |
---|---|
NBitcoin.Transaction | New Transaction Hash - TxId |
GetPubKeyFromSignedScriptPubKey(String)
Declaration
public static PubKey GetPubKeyFromSignedScriptPubKey(string scriptAsm)
Parameters
Type | Name | Description |
---|---|---|
System.String | scriptAsm |
Returns
Type | Description |
---|---|
NBitcoin.PubKey |
GetSendAmount(GetTransactionInfoResponse, String)
Returns sended amount of neblio in some transaction. It counts the outputs which was send to input address
Declaration
public static double GetSendAmount(GetTransactionInfoResponse tx, string address)
Parameters
Type | Name | Description |
---|---|---|
GetTransactionInfoResponse | tx | |
System.String | address | expected address where was nebl send in this tx |
Returns
Type | Description |
---|---|
System.Double |
GetTransactionWithNeblioAndTokensInputs(ICollection<Utxos>, ICollection<Utxos>, BitcoinAddress)
This function will create empty Transaction object based on Neblio network standard Then it add Neblio intpus and tokens inputs and summarize their value
Declaration
public static (Transaction, (double, double)) GetTransactionWithNeblioAndTokensInputs(ICollection<Utxos> nutxos, ICollection<Utxos> tutxos, BitcoinAddress address)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.ICollection<Utxos> | nutxos | |
System.Collections.Generic.ICollection<Utxos> | tutxos | |
NBitcoin.BitcoinAddress | address |
Returns
Type | Description |
---|---|
System.ValueTuple<NBitcoin.Transaction, System.ValueTuple<System.Double, System.Double>> | (Item1 - NBitcoin Transaction object, (Item2.Item1 - sum of all neblio inputs, Item2.Item2 - sum of all tokens) |
GetTransactionWithNeblioInputs(ICollection<Utxos>, BitcoinAddress)
This function will crate empty Transaction object based on Neblio network standard Then add the Neblio Inputs and sumarize their value
Declaration
public static (Transaction, double) GetTransactionWithNeblioInputs(ICollection<Utxos> nutxos, BitcoinAddress address)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.ICollection<Utxos> | nutxos | List of Neblio Utxos to use |
NBitcoin.BitcoinAddress | address | Address of the owner |
Returns
Type | Description |
---|---|
System.ValueTuple<NBitcoin.Transaction, System.Double> | (NBitcoin Transaction object, sum of all inputs values in double) |
IsPrivateKeyValid(String)
Check if the private key is valid for the Neblio Network
Declaration
public static BitcoinSecret IsPrivateKeyValid(string privatekey)
Parameters
Type | Name | Description |
---|---|---|
System.String | privatekey |
Returns
Type | Description |
---|---|
NBitcoin.BitcoinSecret |
IssueTokensAsync(IssueTokenTxData, ICollection<Utxos>, Double)
Issue new tokens. Please check the IssueTokenTxData Dto for input parameters
Declaration
public static async Task<Transaction> IssueTokensAsync(IssueTokenTxData data, ICollection<Utxos> nutxos, double fee = 20000)
Parameters
Type | Name | Description |
---|---|---|
IssueTokenTxData | data | |
System.Collections.Generic.ICollection<Utxos> | nutxos | |
System.Double | fee |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NBitcoin.Transaction> |
Exceptions
Type | Condition |
---|---|
System.Exception |
MintMultiNFTTokenAsync(MintNFTData, Int32, ICollection<Utxos>, ICollection<Utxos>)
Function will Mint NFT with the coppies
Declaration
public static async Task<Transaction> MintMultiNFTTokenAsync(MintNFTData data, int coppies, ICollection<Utxos> nutxos, ICollection<Utxos> tutxos)
Parameters
Type | Name | Description |
---|---|---|
MintNFTData | data | Mint data, please see MintNFTData class for the details |
System.Int32 | coppies | 0 or more coppies - with 0 input it is same as MintNFTTokenAsync |
System.Collections.Generic.ICollection<Utxos> | nutxos | Optional input neblio utxo |
System.Collections.Generic.ICollection<Utxos> | tutxos | Optional input token utxo |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NBitcoin.Transaction> | New Transaction Hash - TxId |
MintMultiNFTTokenAsyncInternal(MintNFTData, Int32, ICollection<Utxos>, ICollection<Utxos>, Boolean, Double)
Function will Mint NFT with the coppies
Declaration
public static async Task<Transaction> MintMultiNFTTokenAsyncInternal(MintNFTData data, int coppies, ICollection<Utxos> nutxos, ICollection<Utxos> tutxos, bool multiTokens, double fee = 20000)
Parameters
Type | Name | Description |
---|---|---|
MintNFTData | data | Mint data, please see MintNFTData class for the details |
System.Int32 | coppies | 0 or more coppies - with 0 input it is same as MintNFTTokenAsync |
System.Collections.Generic.ICollection<Utxos> | nutxos | Optional input neblio utxo |
System.Collections.Generic.ICollection<Utxos> | tutxos | Optional input token utxo |
System.Boolean | multiTokens | If there is the multi token it needs to check if there is no conflict |
System.Double | fee |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NBitcoin.Transaction> | New Transaction Hash - TxId |
MintNFTTokenAsync(MintNFTData, ICollection<Utxos>, ICollection<Utxos>)
Function will Mint NFT from lot of the tokens
Declaration
public static async Task<Transaction> MintNFTTokenAsync(MintNFTData data, ICollection<Utxos> nutxos, ICollection<Utxos> tutxos)
Parameters
Type | Name | Description |
---|---|---|
MintNFTData | data | Mint data, please see MintNFTData class for the details |
System.Collections.Generic.ICollection<Utxos> | nutxos | Optional input neblio utxo |
System.Collections.Generic.ICollection<Utxos> | tutxos | Optional input token utxo |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NBitcoin.Transaction> | New Transaction Hash - TxId |
ParseCustomMetadata(String)
Parse and decompress the custom metadata from the OP_RETURN output
Declaration
public static Dictionary<string, string> ParseCustomMetadata(string metadata)
Parameters
Type | Name | Description |
---|---|---|
System.String | metadata |
Returns
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.String> |
ParseNeblioMessage(GetTransactionInfoResponse)
Parse message from the OP_RETURN data in the tx
Declaration
public static (bool, string) ParseNeblioMessage(GetTransactionInfoResponse txinfo)
Parameters
Type | Name | Description |
---|---|---|
GetTransactionInfoResponse | txinfo |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.String> |
SendMultiTokenAPIAsync(SendTokenTxData, ICollection<Utxos>, Double, Boolean, GetAddressInfoResponse, Double)
Transaction which sends multiple tokens from input to different outputs. For example process of the send Ordered NFT and NFT Receipt in one tx.
Declaration
public static async Task<Transaction> SendMultiTokenAPIAsync(SendTokenTxData data, ICollection<Utxos> nutxos, double fee = 20000, bool isMintingOfCopy = false, GetAddressInfoResponse addinfo = null, double latestblockheight = 0)
Parameters
Type | Name | Description |
---|---|---|
SendTokenTxData | data | |
System.Collections.Generic.ICollection<Utxos> | nutxos | |
System.Double | fee | |
System.Boolean | isMintingOfCopy | |
GetAddressInfoResponse | addinfo | |
System.Double | latestblockheight |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NBitcoin.Transaction> |
Exceptions
Type | Condition |
---|---|
System.Exception |
SendNFTTokenAsync(SendTokenTxData, ICollection<Utxos>, Double, GetAddressInfoResponse, Double)
Function will sent exact NFT. You must fill the input token utxo in data object!
Declaration
public static async Task<Transaction> SendNFTTokenAsync(SendTokenTxData data, ICollection<Utxos> nutxos, double fee = 20000, GetAddressInfoResponse addinfo = null, double latestblockheight = 0)
Parameters
Type | Name | Description |
---|---|---|
SendTokenTxData | data | Send data, please see SendTokenTxData class for the details |
System.Collections.Generic.ICollection<Utxos> | nutxos | Optional input neblio utxo |
System.Double | fee | |
GetAddressInfoResponse | addinfo | |
System.Double | latestblockheight |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NBitcoin.Transaction> | New Transaction Hash - TxId |
SendNTP1TokenLotWithPaymentAPIAsync(SendTokenTxData, Double, ICollection<Utxos>, ICollection<Utxos>)
This function will send Neblio payment together with the token whichc carry some metadata
Declaration
public static async Task<Transaction> SendNTP1TokenLotWithPaymentAPIAsync(SendTokenTxData data, double neblAmount, ICollection<Utxos> nutxos, ICollection<Utxos> tutxos)
Parameters
Type | Name | Description |
---|---|---|
SendTokenTxData | data | Mint data, please see MintNFTData class for the details |
System.Double | neblAmount | Amount of Neblio to send |
System.Collections.Generic.ICollection<Utxos> | nutxos | Optional input neblio utxo |
System.Collections.Generic.ICollection<Utxos> | tutxos | Optional list of the token utxos |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NBitcoin.Transaction> | New Transaction Hash - TxId |
SendNTP1TokenWithPaymentAPIAsync(SendTokenTxData, Double, ICollection<Utxos>, String, Int32)
This function will send Neblio payment together with the token whichc carry some metadata
Declaration
public static async Task<Transaction> SendNTP1TokenWithPaymentAPIAsync(SendTokenTxData data, double neblAmount, ICollection<Utxos> nutxos, string paymentUtxoToReturn = null, int paymentUtxoIndexToReturn = 0)
Parameters
Type | Name | Description |
---|---|---|
SendTokenTxData | data | Mint data, please see MintNFTData class for the details |
System.Double | neblAmount | Amount of Neblio to send |
System.Collections.Generic.ICollection<Utxos> | nutxos | Optional input neblio utxo |
System.String | paymentUtxoToReturn | If you returning some payment fill this |
System.Int32 | paymentUtxoIndexToReturn | If you returning some payment fill this |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NBitcoin.Transaction> | New Transaction Hash - TxId |
SendTokenLotNewAsync(SendTokenTxData, ICollection<Utxos>, ICollection<Utxos>, Double)
Send lot of the tokens. It means more than 1 token in one output. Please check the SendTokenTxData Dto for input parameters
Declaration
public static Transaction SendTokenLotNewAsync(SendTokenTxData data, ICollection<Utxos> nutxos, ICollection<Utxos> tutxos, double fee = 20000)
Parameters
Type | Name | Description |
---|---|---|
SendTokenTxData | data | |
System.Collections.Generic.ICollection<Utxos> | nutxos | |
System.Collections.Generic.ICollection<Utxos> | tutxos | |
System.Double | fee |
Returns
Type | Description |
---|---|
NBitcoin.Transaction |
Exceptions
Type | Condition |
---|---|
System.Exception |
SendTokensToMultipleReceiversAsync(SendTokenTxData, ICollection<Utxos>, ICollection<Utxos>, Double)
Send Tokens to multiple receivers with different amounts of the tokens
Declaration
public static async Task<Transaction> SendTokensToMultipleReceiversAsync(SendTokenTxData data, ICollection<Utxos> nutxos, ICollection<Utxos> tutxos, double fee = 20000)
Parameters
Type | Name | Description |
---|---|---|
SendTokenTxData | data | Mint data, please see SendTokenTxData class for the details |
System.Collections.Generic.ICollection<Utxos> | nutxos | Optional input neblio utxo |
System.Collections.Generic.ICollection<Utxos> | tutxos | Optional input token utxo |
System.Double | fee |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NBitcoin.Transaction> | New Transaction Hash - TxId |
SignAndBroadcast(Transaction, BitcoinSecret, Boolean, List<Utxos>)
Function will sign transaction with provided key and broadcast with Neblio API
Declaration
public static async Task<string> SignAndBroadcast(Transaction transaction, BitcoinSecret key, bool withBroadcast = true, List<Utxos> addrutxos = null)
Parameters
Type | Name | Description |
---|---|---|
NBitcoin.Transaction | transaction | NBitcoin Transaction object |
NBitcoin.BitcoinSecret | key | NBitcoin Key - must contain Private Key |
System.Boolean | withBroadcast | |
System.Collections.Generic.List<Utxos> | addrutxos |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | New Transaction Hash - TxId |
SignAndBroadcastTransaction(Transaction, BitcoinSecret)
Wrap for SignAndBroadcast transaction function
Declaration
public static async Task<string> SignAndBroadcastTransaction(Transaction transaction, BitcoinSecret key)
Parameters
Type | Name | Description |
---|---|---|
NBitcoin.Transaction | transaction | |
NBitcoin.BitcoinSecret | key |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> |
SplitNeblioCoinTransactionAPIAsync(String, List<String>, Int32, Double, ICollection<Utxos>)
Function will send standard Neblio transaction
Declaration
public static async Task<Transaction> SplitNeblioCoinTransactionAPIAsync(string address, List<string> receivers, int lots, double amount, ICollection<Utxos> nutxos)
Parameters
Type | Name | Description |
---|---|---|
System.String | address | |
System.Collections.Generic.List<System.String> | receivers | |
System.Int32 | lots | |
System.Double | amount | |
System.Collections.Generic.ICollection<Utxos> | nutxos | Optional input neblio utxo |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NBitcoin.Transaction> | New Transaction Hash - TxId |
SplitNTP1TokensAsync(String, List<String>, Int32, Int32, String, IDictionary<String, String>, ICollection<Utxos>, ICollection<Utxos>)
Function will Split NTP1 tokens to smaller lots receiver list - If you input 0, split will be done to sender address, if you input 1 receiver split will be done to receiver (all inputs) if you will provide multiple receivers, the number of lots and receivers must match.
Declaration
public static async Task<Transaction> SplitNTP1TokensAsync(string address, List<string> receiver, int lots, int amount, string tokenId, IDictionary<string, string> metadata, ICollection<Utxos> nutxos, ICollection<Utxos> tutxos)
Parameters
Type | Name | Description |
---|---|---|
System.String | address | |
System.Collections.Generic.List<System.String> | receiver | List of receivers. |
System.Int32 | lots | |
System.Int32 | amount | |
System.String | tokenId | |
System.Collections.Generic.IDictionary<System.String, System.String> | metadata | |
System.Collections.Generic.ICollection<Utxos> | nutxos | Optional input neblio utxo |
System.Collections.Generic.ICollection<Utxos> | tutxos | Optional input token utxo |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<NBitcoin.Transaction> | New Transaction Hash - TxId |
ValidateNeblioAddress(String)
Validate if the Neblio address is the correct
Declaration
public static string ValidateNeblioAddress(string neblioAddress)
Parameters
Type | Name | Description |
---|---|---|
System.String | neblioAddress |
Returns
Type | Description |
---|---|
System.String |
Events
| Improve this Doc View SourceNewEventInfo
Main event info handler
Declaration
public static event EventHandler<IEventInfo> NewEventInfo
Event Type
Type | Description |
---|---|
System.EventHandler<IEventInfo> |