The Go Playground

Category: Mercados

btcsuite wire

An alternative full node bitcoin implementation written in Go (golang) - a Go package on Go - conwaytransport.com.au An error occurred while fetching folder content. 46ca86f01c3bfcffd87e56adf3bc Switch branch/tag. burrow · vendor · conwaytransport.com.au · btcsuite · btcd. import "conwaytransport.com.au". Package wire implements the bitcoin wire protocol. For the complete details of the bitcoin protocol, see the official wiki. btcsuite wire

Golang DoubleSha Examples

// DecodeWIF creates a new WIF structure by decoding the string encoding of // the import format. // // The WIF string must be a baseencoded string of the following byte // sequence: // // * 1 byte to identify the network, must be 0x80 for mainnet or 0xef for // either testnet3 or the regression test network // * 32 bytes of a binary-encoded, big-endian, zero-padded private key // * Optional 1 byte (equal to 0x01) if the address being imported or exported // was created by taking the RIPEMD after SHA hash of a serialized // compressed (byte) public key // * 4 bytes of checksum, must equal the first four bytes of the double SHA // of every byte before the checksum in this sequence // // If the basedecoded byte sequence does not match this, DecodeWIF will // return a non-nil error. ErrMalformedPrivateKey is returned when the WIF // is of an impossible length or the expected compressed pubkey magic number // does not equal the expected value of 0x ErrChecksumMismatch is returned // if the expected WIF checksum does not match the calculated checksum. func DecodeWIF(wif string) (*WIF, error) { decoded := baseDecode(wif) decodedLen := len(decoded) var compress bool // Length of base58 decoded WIF must be 32 bytes + an optional 1 byte // (0x01) if compressed, plus 1 byte for netID + 4 bytes of checksum. switch decodedLen { case 1 + conwaytransport.com.auyBytesLen + 1 + 4: if decoded[33] != compressMagic { return nil, ErrMalformedPrivateKey } compress = true case 1 + conwaytransport.com.auyBytesLen + 4: compress = false default: return nil, ErrMalformedPrivateKey } // Checksum is first four bytes of double SHA of the identifier byte // and privKey. Verify this matches the final 4 bytes of the decoded // private key. var tosum []byte if compress { tosum = decoded[:1+conwaytransport.com.auyBytesLen+1] } else { tosum = decoded[:1+conwaytransport.com.auyBytesLen] } cksum := conwaytransport.com.auSha(tosum)[:4] if !conwaytransport.com.au(cksum, decoded[decodedLen]) { return nil, ErrChecksumMismatch } netID := decoded[0] privKeyBytes := decoded[1 : 1+conwaytransport.com.auyBytesLen] privKey, _ := conwaytransport.com.auyFromBytes(btcec.S(), privKeyBytes) return &WIF{privKey, compress, netID}, nil }
Источник: conwaytransport.com.au

By -

1 thoughts on “Btcsuite wire”

Leave a Reply

Your email address will not be published. Required fields are marked *