rosettaFilecoinLib

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2020 License: Apache-2.0 Imports: 13 Imported by: 8

README

rosetta-filecoin-lib

stability-wip License CircleCI

Documentation

Overview

****************************************************************************** * (c) 2020 Zondax GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultisigPaymentParams

type MultisigPaymentParams struct {
	To       string `json:"to"`
	Quantity uint64 `json:"quantity"`
}

MultisigPaymentParams defines params for MultisigPaymentRequest

type MultisigPaymentRequest

type MultisigPaymentRequest struct {
	Multisig string                `json:"multisig"`
	From     string                `json:"from"`
	Quantity uint64                `json:"quantity"`
	Metadata TxMetadata            `json:"metadata"`
	Params   MultisigPaymentParams `json:"params"`
}

MultisigPaymentRequest defines the input to ConstructMultisigPayment

type PaymentRequest

type PaymentRequest struct {
	From     string     `json:"from"`
	To       string     `json:"to"`
	Quantity uint64     `json:"quantity"`
	Metadata TxMetadata `json:"metadata"`
}

PaymentRequest defines the input to ConstructPayment

type RosettaConstructionFilecoin

type RosettaConstructionFilecoin struct {
	Mainnet bool
}

func (RosettaConstructionFilecoin) ConstructMultisigPayment

func (r RosettaConstructionFilecoin) ConstructMultisigPayment(request *MultisigPaymentRequest) (string, error)

func (RosettaConstructionFilecoin) ConstructPayment

func (r RosettaConstructionFilecoin) ConstructPayment(request *PaymentRequest) (string, error)

func (RosettaConstructionFilecoin) ConstructSwapAuthorizedParty

func (r RosettaConstructionFilecoin) ConstructSwapAuthorizedParty(request *SwapAuthorizedPartyRequest) (string, error)

func (RosettaConstructionFilecoin) DeriveFromPublicKey

func (r RosettaConstructionFilecoin) DeriveFromPublicKey(publicKey []byte) (string, error)

func (RosettaConstructionFilecoin) Hash

func (r RosettaConstructionFilecoin) Hash(signedMessage string) (string, error)

func (RosettaConstructionFilecoin) ParseTx

func (r RosettaConstructionFilecoin) ParseTx(messageBase64 string) (string, error)

func (RosettaConstructionFilecoin) Sign

func (r RosettaConstructionFilecoin) Sign(message []byte, sk []byte) ([]byte, error)

func (RosettaConstructionFilecoin) SignTx

func (r RosettaConstructionFilecoin) SignTx(unsignedTxBase64 string, privateKey []byte) (string, error)

func (RosettaConstructionFilecoin) Verify

func (r RosettaConstructionFilecoin) Verify(message []byte, publicKey []byte, signature []byte) error

type RosettaConstructionTool

type RosettaConstructionTool interface {
	// DeriveFromPublicKey defines the function to derive the address from an public key (secp256k1)
	// @return
	//   - derivedAddress [string]
	//   - error when deriving address from the public key
	DeriveFromPublicKey(publicKey []byte) (string, error)

	// Sign defines the function to sign an arbitrary message with the secret key (secp256k1)
	// @return (secp256k1)
	//   - signature [string] the signature after the message is signed with the private key
	//   - error when signing a message
	Sign(message []byte, sk []byte) ([]byte, error)

	// Verify defines the function to verify the signature of an arbitrary message with the public key (secp256k1)
	// @return
	//   - error if invalid signature
	Verify(message []byte, publicKey []byte, signature []byte) error

	// ConstructPayment creates transaction for a normal send
	// @return
	//   - unsignedTx [string] base64 encoded unsigned transaction
	//   - error while constructing the normal send transaction
	ConstructPayment(request *PaymentRequest) (string, error)

	// ConstructMultisigPayment creates transaction for a multisig send
	// @return
	//   - unsignedTx [string] base64 encoded unsigned transaction
	//   - error while constructing the multisig send transaction
	ConstructMultisigPayment(request *MultisigPaymentRequest) (string, error)

	// ConstructSwapAuthorizedParty creates transaction for a multisig SwapAuthorizedParty call
	// @return
	//   - unsignedTx [string] base64 encoded unsigned transaction
	//   - error while constructing the multisig SwapAuthorizedParty call
	ConstructSwapAuthorizedParty(request *MultisigPaymentRequest) (string, error)

	// SignTx signs an unsignedTx using the secret key (secp256k1) and return a signedTx that can be submitted to the node
	// @unsignedTransaction [string] base64 encoded unsigned transaction
	// @sk [[]byte] secp256k1 secret key
	// @return
	//   - signedTx [string] the signed transaction
	//   - error when signing a transaction
	SignTx(unsignedTransaction string, sk []byte) (string, error)

	// ParseTx defines the function to parse a transaction
	// @tx [string] signed or unsigned transaction base64 encoded
	// @return
	//   - message [string] the parsed transaction (message or unsigned message) represented as a base64 string
	//   - error when parsing a transaction
	ParseTx(tx string) (string, error)

	// Hash defines the function to calculate a tx hash
	// @signedTx [string] base64 encoded signed transaction
	// @return
	//   - txHash [string] transaction hash
	//   - error when calculating the tx hash
	Hash(signedTx string) (string, error)
}

type SwapAuthorizedPartyParams

type SwapAuthorizedPartyParams struct {
	From string `json:"from"`
	To   string `json:"to"`
}

SwapAuthorizedPartyParams defines the params

type SwapAuthorizedPartyRequest

type SwapAuthorizedPartyRequest struct {
	Multisig string                    `json:"multisig"`
	From     string                    `json:"from"`
	Metadata TxMetadata                `json:"metadata"`
	Params   SwapAuthorizedPartyParams `json:"params"`
}

SwapAuthorizedPartyRequest defines the input to ConstructSwapAuthorizedParty

type TxMetadata

type TxMetadata struct {
	Nonce      uint64 `json:"nonce"`
	GasFeeCap  int64  `json:"gas_fee_cap"`
	GasPremium int64  `json:"gas_premium"`
	GasLimit   int64  `json:"gas_limit,omitempty"`
	ChainID    string `json:"chain_id,omitempty"`
	Method     uint64 `json:"method,omitempty"`
	Params     []byte `json:"params,omitempty"`
}

Modify this as needed to add in new fields

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL