Skip to content

Commit

Permalink
Merge pull request #62 from immutability-io/raw-tx
Browse files Browse the repository at this point in the history
Raw tx
  • Loading branch information
cypherhat committed Jun 22, 2019
2 parents c0c3132 + 959eb49 commit 7bcd2ac
Show file tree
Hide file tree
Showing 1,359 changed files with 456,324 additions and 132 deletions.
21 changes: 12 additions & 9 deletions API.md
Expand Up @@ -371,7 +371,8 @@ This endpoint will sign the provided transaction.
* `gas_price` (`string: <optional>`) - The price in gas for the transaction. If omitted, we will use the suggested gas price.
* `gas_limit` (`string: <optional>`) - The gas limit for the transaction. If omitted, we will estimate the gas limit.
* `nonce` (`string: <optional>`) - The nonce for the transaction. If omitted or zero, we will use the suggested nonce.
* `data` (`string: <required>`) - Transaction data to sign.
* `data` (`string: <required>`) - The data to sign or the absolute path of a file containing the data.
* `dataIsFile` (`bool: <optional> - defaults to false`) - TThe data to sign is stored in a file.

#### Sample Payload

Expand All @@ -380,8 +381,10 @@ This endpoint will sign the provided transaction.
{
"amount":"200000000000000000",
"to": "0x36D1F896E55a6577C62FDD6b84fbF74582266700",
"data": "transaction data"
"data": "/Volumes/ext/go/src/github.com/immutability-io/vault-ethereum/scripts/transaction.data",
"dataIsFile": true
}

```

#### Sample Request
Expand All @@ -404,17 +407,17 @@ The example below shows output for the successful signing of a transaction by th
"lease_duration": 0,
"renewable": false,
"data": {
"amount": "100000000000000000",
"address_from": "0xb404e6057248e2be41e5d35bebcb313be5097ed7",
"address_to": "0x36D1F896E55a6577C62FDD6b84fbF74582266700",
"amount": "200000000000000000",
"amount_in_usd": "0",
"address_from": "0x4169c9508728285e8a9f7945d08645bb6b3576e5",
"address_to": "0x8AC5e6617F65c071f6dD5d7bD400bf4a46434D41",
"gas_limit": "21000",
"gas_price": "1000000000",
"signed_transaction": "0xf86b06843b9aca00825208948ac5e6617f65c071f6dd5d7bd400bf4a46434d4188016345785d8a0000802ca0ff3fccbde1964047db6be33410436a9220c91ea4080b0e14489dc35fbdabd008a0448fe3ec216a639e1b0eb87b0e4b20aab2e5ec46dad4c38cfc81a1c54e309d21",
"starting_balance": 8460893507395267000,
"signed_transaction": "0xf87b80843b9aca008252089436d1f896e55a6577c62fdd6b84fbf745822667008802c68af0bb140000907472616e73616374696f6e20646174612ba0bd3da3fdd8ca70d366ad966c5a380d659e7dd02d0c80cf42e4049cb910db78bea004dcb254858a46d0264448531ef04d9b13e9dcb8b7728d927b0ff72b3f06aeaf",
"starting_balance": 3000000000000000000,
"starting_balance_in_usd": "0",
"total_spend": "100000000000000000",
"transaction_hash": "0x3a103587ea6bdeee944e5f68f90ed7b1f4c7699236167d1b1d29495b0319fb26"
"total_spend": "2400000000000000000",
"transaction_hash": "0x0a9e5b92b7d9c7bad30252d7af34519f117aa5e669e16c2287a0d11a0f9c2adf"
},
"warnings": null
}
Expand Down
28 changes: 14 additions & 14 deletions backend.go
Expand Up @@ -18,19 +18,16 @@ import (
"context"
"fmt"

"github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/logical/framework"
"github.com/hashicorp/vault/sdk/framework"
"github.com/hashicorp/vault/sdk/logical"
)

// New returns a new backend as an interface. This func
// is only necessary for builtin backend plugins.
func New() (interface{}, error) {
return Backend(), nil
}

// Factory returns a new backend as logical.Backend.
// Factory returns the backend
func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
b := Backend()
b, err := Backend(conf)
if err != nil {
return nil, err
}
if err := b.Setup(ctx, conf); err != nil {
return nil, err
}
Expand All @@ -40,17 +37,20 @@ func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend,
// FactoryType returns the factory
func FactoryType(backendType logical.BackendType) logical.Factory {
return func(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
b := Backend()
b, err := Backend(conf)
if err != nil {
return nil, err
}
b.BackendType = backendType
if err := b.Setup(ctx, conf); err != nil {
if err = b.Setup(ctx, conf); err != nil {
return nil, err
}
return b, nil
}
}

// Backend returns the backend
func Backend() *EthereumBackend {
func Backend(conf *logical.BackendConfig) (*EthereumBackend, error) {
var b EthereumBackend
b.Backend = &framework.Backend{
Help: "",
Expand Down Expand Up @@ -81,7 +81,7 @@ func Backend() *EthereumBackend {
Secrets: []*framework.Secret{},
BackendType: logical.TypeLogical,
}
return &b
return &b, nil
}

// EthereumBackend implements the Backend for this plugin
Expand Down
40 changes: 12 additions & 28 deletions go.mod
@@ -1,40 +1,24 @@
module github.com/immutability-io/vault-ethereum

go 1.12

require (
github.com/SermoDigital/jose v0.9.1 // indirect
github.com/allegro/bigcache v1.1.0 // indirect
github.com/aristanetworks/goarista v0.0.0-20190201223726-e2363f69bde9 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/allegro/bigcache v1.2.1 // indirect
github.com/aristanetworks/goarista v0.0.0-20190607111240-52c2a7864a08 // indirect
github.com/btcsuite/btcd v0.0.0-20190614013741-962a206e94e9 // indirect
github.com/deckarep/golang-set v1.7.1 // indirect
github.com/ethereum/go-ethereum v1.8.22
github.com/ethereum/go-ethereum v1.8.27
github.com/go-stack/stack v1.8.0 // indirect
github.com/hashicorp/errwrap v1.0.0
github.com/hashicorp/go-hclog v0.0.0-20190109152822-4783caec6f2e // indirect
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
github.com/hashicorp/go-plugin v0.0.0-20190129155509-362c99b11937 // indirect
github.com/hashicorp/go-retryablehttp v0.5.2 // indirect
github.com/hashicorp/go-rootcerts v1.0.0 // indirect
github.com/hashicorp/go-sockaddr v1.0.1 // indirect
github.com/hashicorp/go-uuid v1.0.1 // indirect
github.com/hashicorp/go-version v1.1.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/vault v1.0.2
github.com/mattn/go-isatty v0.0.4 // indirect
github.com/miguelmota/go-coinmarketcap v0.1.0
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/hashicorp/vault/api v1.0.2
github.com/hashicorp/vault/sdk v0.1.11
github.com/miguelmota/go-coinmarketcap v0.1.4
github.com/pborman/uuid v1.2.0
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
github.com/posener/complete v1.1.2 // indirect
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/rs/cors v1.6.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/sethvargo/go-diceware v0.0.0-20181024230814-74428ac65346
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24
github.com/stretchr/objx v0.1.1 // indirect
github.com/syndtr/goleveldb v0.0.0-20190203031304-2f17a3356c66 // indirect
golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c // indirect
google.golang.org/grpc v1.18.0 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
github.com/syndtr/goleveldb v1.0.0 // indirect
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
)

0 comments on commit 7bcd2ac

Please sign in to comment.