C# Класс BitSharper.Script

BitCoin transactions don't specify what they do directly. Instead a small binary stack language is used to define programs that when evaluated return whether the transaction "accepts" or rejects the other transactions connected to it.
This implementation of the scripting language is incomplete. It contains enough support to run standard transactions generated by the official client, but non-standard transactions will fail.
Показать файл Открыть проект

Открытые методы

Метод Описание
Script ( NetworkParameters @params, byte programBytes, int offset, int length ) : System

Construct a Script using the given network parameters and a range of the programBytes array.

ToString ( ) : string

Returns the program opcodes as a string, for example "[1234] DUP HAHS160"

Приватные методы

Метод Описание
CreateInputScript ( byte signature, byte pubkey ) : byte[]
CreateOutputScript ( Address to ) : byte[]
CreateOutputScript ( byte pubkey ) : byte[]

Create a script that sends coins directly to the given public key (eg in a coinbase transaction).

GetData ( int len ) : byte[]
Parse ( byte programBytes, int offset, int length ) : void

To run a script, first we parse it which breaks it up into chunks representing pushes of data or logical opcodes. Then we can run the parsed chunks.

The reason for this split, instead of just interpreting directly, is to make it easier to reach into a programs structure and pull out bits of data without having to run it. This is necessary to render the to/from addresses of transactions in a user interface. The official client does something similar.

ReadByte ( ) : byte
WriteBytes ( Stream os, byte buf ) : void

Writes out the given byte buffer to the output stream with the correct opcode prefix

Описание методов

Script() публичный Метод

Construct a Script using the given network parameters and a range of the programBytes array.
public Script ( NetworkParameters @params, byte programBytes, int offset, int length ) : System
@params NetworkParameters
programBytes byte Array of program bytes from a transaction.
offset int How many bytes into programBytes to start reading from.
length int How many bytes to read.
Результат System

ToString() публичный Метод

Returns the program opcodes as a string, for example "[1234] DUP HAHS160"
public ToString ( ) : string
Результат string