Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: Colin/store #153

Merged
merged 57 commits into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
148cb24
kvstore is a private member
hamdiallam May 8, 2019
c8126e7
query routes for utxo
hamdiallam May 8, 2019
05813cf
Merge branch 'hamdi/query' of github.com:FourthState/plasma-mvp-sidec…
colin-axner May 8, 2019
5f8b0f3
message when no utxos are available
hamdiallam May 8, 2019
7e1a4b9
change to deposit, block, and tx store
colin-axner May 9, 2019
1736b1e
block querier. store utxo already satisfies rlp interface
hamdiallam May 10, 2019
960027b
adjusting inputs outputs to be variable, updated app
colin-axner May 10, 2019
ffc5ad1
file rename. remove resp objects
hamdiallam May 10, 2019
87501a1
refactored plasma/, updated tests
colin-axner May 10, 2019
c4358e2
updated msgs/
colin-axner May 10, 2019
0943e9c
refactored handlers/ still need to update tests
colin-axner May 10, 2019
4fb3b12
merge with hamdis branch
colin-axner May 10, 2019
65a44f0
Fix build errors and test issue in store/
colin-axner May 10, 2019
e8e5418
added tests for deposit and block stores
colin-axner May 11, 2019
4a9f92a
added tests to store, failing on deep equal
colin-axner May 11, 2019
591b3ac
wip rest server
hamdiallam May 11, 2019
db089bf
revert spend to original functionality
hamdiallam May 11, 2019
f22b65c
store test bug fix
colin-axner May 13, 2019
fb1fd2d
merge rest branch
colin-axner May 13, 2019
e79b8e5
added account, updated querier
colin-axner May 14, 2019
714b0ed
commit current work, prep to merge deposit/tx stores
colin-axner May 15, 2019
5c790db
updated output store
colin-axner May 15, 2019
b8582c3
deleted depositStore, fixed bugs in outputStore
colin-axner May 15, 2019
9ea2295
refactored handlers/ tests
colin-axner May 16, 2019
0691dec
added fee support to store/ with tests
colin-axner May 16, 2019
9736100
in progress work being committed for review
colin-axner May 31, 2019
0cbbb1a
query metadata about 10 blocks
hamdiallam Jun 4, 2019
7c60051
blocks query commond and likewise rest interface
hamdiallam Jun 4, 2019
9dd6071
SubmitBlock test no longer applicable
hamdiallam Jun 4, 2019
d3eed28
merged develop
hamdiallam Jun 4, 2019
28d9f2a
reflect some pr comments
colin-axner Jun 5, 2019
d0314d3
merge with hamdis
colin-axner Jun 5, 2019
a2352d2
update client query, handler err fixes
colin-axner Jun 5, 2019
c5a2ef6
some more refactor on cli
colin-axner Jun 6, 2019
62ac312
change account to wallet
colin-axner Jun 8, 2019
8094c0e
consolidate verifyandsign func
colin-axner Jun 8, 2019
0c5a538
improves output store and prove
AdityaSripal Jun 19, 2019
5fdb575
finish prove and fmt
AdityaSripal Jun 19, 2019
2714487
revert mistake
AdityaSripal Jun 19, 2019
6111e2e
merge
colin-axner Jun 26, 2019
5e6198e
some refactors on comments and pr comments
colin-axner Jun 26, 2019
7224c29
updated store querying
colin-axner Jun 30, 2019
6d93383
merge develop
colin-axner Jun 30, 2019
ba63648
fix various build/merge issue
colin-axner Jun 30, 2019
52f5487
cli fixes
colin-axner Jul 1, 2019
3010eb9
rm todos
colin-axner Jul 1, 2019
f4cce13
store fee
colin-axner Jul 1, 2019
c4436e2
validateBasic change
AdityaSripal Jul 2, 2019
278cbf3
Merge branch 'colin/store' of github.com:FourthState/plasma-mvp-sidec…
AdityaSripal Jul 2, 2019
d9926bd
fix bugs
AdityaSripal Jul 2, 2019
527d879
Apply suggestions from code review: Doc fixes
AdityaSripal Jul 2, 2019
b1eec74
address some pr comments
colin-axner Jul 2, 2019
214ae35
build fix
colin-axner Jul 3, 2019
4af2bf2
reflect my own pr comments
colin-axner Jul 5, 2019
41a5024
error update
colin-axner Jul 5, 2019
780f3ea
changelog and updated err in ante
colin-axner Jul 6, 2019
b9ecdab
update changelog
colin-axner Jul 8, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Plasma configuration file
- Added IncludeDepositMsg with handling to allow explicit deposit inclusion into sidechain
### Changed
- [\#153](https://github.com/FourthState/plasma-mvp-sidechain/pull/153) Major refactor of store/, can query with position, transaction hash, or address. REST Supported.
- [\#141](https://github.com/FourthState/plasma-mvp-sidechain/pull/141) Dependency management is now handled by go modules instead of Dep
- [\#129](https://github.com/FourthState/plasma-mvp-sidechain/pull/129) Updated sign command to iterate over an account to finalize transactions
- [\#129](https://github.com/FourthState/plasma-mvp-sidechain/pull/129) Updated spend to auto generate transaction for users based on the utxos they own
Expand All @@ -36,7 +37,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- [\#147](https://github.com/FourthState/plasma-mvp-sidechain/pull/147) Fix Syncing bug where syncing nodes would panic after processing exitted inputs/deposits. Bug is explained in detail here: [\#143](https://github.com/FourthState/plasma-mvp-sidechain/issues/143)
- [\#154](https://github.com/FourthState/plasma-mvp-sidechain/pull/154) Fixes issue where include-Deposit msg.Owner == deposit.Owner not enforced. This is necessary to prevent malicious users from rewriting an already included UTXO in store.
### Deprecated
- Dep is no longer be supported
- Dep is no longer supported

## PreHistory

Expand Down
51 changes: 23 additions & 28 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ type PlasmaMVPChain struct {
feeAmount *big.Int

// persistent stores
utxoStore store.UTXOStore
plasmaStore store.PlasmaStore
outputStore store.OutputStore
blockStore store.BlockStore

// smart contract connection
ethConnection *eth.Plasma
Expand All @@ -58,18 +58,19 @@ func NewPlasmaMVPChain(logger log.Logger, db dbm.DB, traceStore io.Writer, optio
cdc := MakeCodec()
baseApp.SetCommitMultiStoreTracer(traceStore)

utxoStoreKey := sdk.NewKVStoreKey("utxo")
utxoStore := store.NewUTXOStore(utxoStoreKey)
plasmaStoreKey := sdk.NewKVStoreKey("plasma")
plasmaStore := store.NewPlasmaStore(plasmaStoreKey)
outputStoreKey := sdk.NewKVStoreKey("outputs")
outputStore := store.NewOutputStore(outputStoreKey)
blockStoreKey := sdk.NewKVStoreKey("block")
blockStore := store.NewBlockStore(blockStoreKey)

app := &PlasmaMVPChain{
BaseApp: baseApp,
cdc: cdc,
txIndex: 0,
feeAmount: big.NewInt(0), // we do not use `utils.BigZero` because the feeAmount is going to be updated

utxoStore: utxoStore,
plasmaStore: plasmaStore,
blockStore: blockStore,
outputStore: outputStore,
}

// set configs
Expand Down Expand Up @@ -116,25 +117,25 @@ func NewPlasmaMVPChain(logger log.Logger, db dbm.DB, traceStore io.Writer, optio
app.feeAmount = app.feeAmount.Add(app.feeAmount, amt)
return nil
}
app.Router().AddRoute(msgs.SpendMsgRoute, handlers.NewSpendHandler(app.utxoStore, app.plasmaStore, nextTxIndex, feeUpdater))
app.Router().AddRoute(msgs.IncludeDepositMsgRoute, handlers.NewDepositHandler(app.utxoStore, app.plasmaStore, nextTxIndex, plasmaClient))
app.Router().AddRoute(msgs.SpendMsgRoute, handlers.NewSpendHandler(app.outputStore, app.blockStore, nextTxIndex, feeUpdater))
app.Router().AddRoute(msgs.IncludeDepositMsgRoute, handlers.NewDepositHandler(app.outputStore, app.blockStore, nextTxIndex, plasmaClient))

// custom queriers
app.QueryRouter().
AddRoute("utxo", query.NewUtxoQuerier(utxoStore)).
AddRoute("plasma", query.NewPlasmaQuerier(plasmaStore))
AddRoute(store.QueryOutputStore, query.NewOutputQuerier(outputStore)).
AddRoute(store.QueryBlockStore, query.NewBlockQuerier(blockStore))

// Set the AnteHandler
app.SetAnteHandler(handlers.NewAnteHandler(app.utxoStore, app.plasmaStore, plasmaClient))
app.SetAnteHandler(handlers.NewAnteHandler(app.outputStore, app.blockStore, plasmaClient))

// set the rest of the chain flow
app.SetEndBlocker(app.endBlocker)
app.SetInitChainer(app.initChainer)

// mount and load stores
// IAVL store used by default. `fauxMerkleMode` defaults to false
app.MountStores(utxoStoreKey, plasmaStoreKey)
if err := app.LoadLatestVersion(utxoStoreKey); err != nil {
app.MountStores(outputStoreKey, blockStoreKey)
if err := app.LoadLatestVersion(outputStoreKey); err != nil {
fmt.Println(err)
os.Exit(1)
}
Expand Down Expand Up @@ -163,7 +164,7 @@ func (app *PlasmaMVPChain) endBlocker(ctx sdk.Context, req abci.RequestEndBlock)
// skip if the block is empty
if app.txIndex == 0 {
// try to commit any headers in the store
app.ethConnection.CommitPlasmaHeaders(ctx, app.plasmaStore)
app.ethConnection.CommitPlasmaHeaders(ctx, app.blockStore)
return abci.ResponseEndBlock{}
}

Expand All @@ -172,20 +173,14 @@ func (app *PlasmaMVPChain) endBlocker(ctx sdk.Context, req abci.RequestEndBlock)
var header [32]byte
copy(header[:], ctx.BlockHeader().DataHash)
block := plasma.NewBlock(header, app.txIndex, app.feeAmount)
plasmaBlockNum := app.plasmaStore.StoreBlock(ctx, tmBlockHeight, block)
app.ethConnection.CommitPlasmaHeaders(ctx, app.plasmaStore)

if app.feeAmount.Sign() != 0 {
// add a utxo in the store with position 2^16-1
utxo := store.UTXO{
Position: plasma.NewPosition(plasmaBlockNum, 1<<16-1, 0, nil),
Output: plasma.NewOutput(app.operatorAddress, app.feeAmount),
Spent: false,
}

app.utxoStore.StoreUTXO(ctx, utxo)
app.blockStore.StoreBlock(ctx, tmBlockHeight, block)

if app.feeAmount.Sign() == 1 {
app.outputStore.StoreFee(ctx, app.blockStore.PlasmaBlockHeight(ctx), plasma.NewOutput(app.operatorAddress, app.feeAmount))
}

app.ethConnection.CommitPlasmaHeaders(ctx, app.blockStore)

app.txIndex = 0
app.feeAmount = big.NewInt(0)

Expand Down
14 changes: 1 addition & 13 deletions cmd/plasmacli/subcmd/eth/challenge.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import (
"github.com/FourthState/plasma-mvp-sidechain/cmd/plasmacli/config"
ks "github.com/FourthState/plasma-mvp-sidechain/cmd/plasmacli/store"
"github.com/FourthState/plasma-mvp-sidechain/plasma"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
ethcmn "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/spf13/cobra"
"github.com/spf13/viper"
tm "github.com/tendermint/tendermint/rpc/core/types"
Expand All @@ -19,7 +16,6 @@ import (
func ChallengeCmd() *cobra.Command {
config.AddPersistentTMFlags(challengeCmd)
challengeCmd.Flags().StringP(gasLimitF, "g", "300000", "gas limit for ethereum transaction")
challengeCmd.Flags().String(ownerF, "", "owner of the challenging transaction, required if different from the specified account")
challengeCmd.Flags().String(proofF, "", "merkle proof of inclusion")
challengeCmd.Flags().String(sigsF, "", "confirmation signatures for the challenging transaction")
challengeCmd.Flags().Bool(useNodeF, false, "trust connected full node")
Expand All @@ -41,7 +37,6 @@ Usage:
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
viper.BindPFlags(cmd.Flags())
ctx := context.NewCLIContext()

// parse positions
exitingPos, err := plasma.FromPositionString(args[0])
Expand All @@ -64,13 +59,6 @@ Usage:
return fmt.Errorf("failed to retrieve account key: { %s }", err)
}

var owner ethcmn.Address
if viper.GetString(ownerF) != "" {
owner = ethcmn.HexToAddress(viper.GetString(ownerF))
} else {
owner = crypto.PubkeyToAddress(key.PublicKey)
}

// bind key
auth := bind.NewKeyedTransactor(key)
transactOpts := &bind.TransactOpts{
Expand All @@ -82,7 +70,7 @@ Usage:
var txBytes, proof, confirmSignatures []byte
if viper.GetBool(useNodeF) {
var result *tm.ResultTx
result, confirmSignatures, err = getProof(ctx, owner, challengingPos)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was the context parameter removed? I think each command should be responsible for constructing it's context object with the plasmad node

result, confirmSignatures, err = getProof(challengingPos)
if err != nil {
return fmt.Errorf("failed to retrieve exit information: { %s }", err)
}
Expand Down
6 changes: 1 addition & 5 deletions cmd/plasmacli/subcmd/eth/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import (
"github.com/FourthState/plasma-mvp-sidechain/cmd/plasmacli/config"
ks "github.com/FourthState/plasma-mvp-sidechain/cmd/plasmacli/store"
"github.com/FourthState/plasma-mvp-sidechain/plasma"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
ethcmn "github.com/ethereum/go-ethereum/common"
eth "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/spf13/cobra"
"github.com/spf13/viper"
tm "github.com/tendermint/tendermint/rpc/core/types"
Expand Down Expand Up @@ -46,7 +44,6 @@ Transaction Exit Usage:
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) (err error) {
viper.BindPFlags(cmd.Flags())
ctx := context.NewCLIContext()
var tx *eth.Transaction

// parse position
Expand All @@ -70,7 +67,6 @@ Transaction Exit Usage:
if err != nil {
return fmt.Errorf("failed to retrieve account key: { %s }", err)
}
addr := crypto.PubkeyToAddress(key.PublicKey)

// bind key, generate transact opts
auth := bind.NewKeyedTransactor(key)
Expand Down Expand Up @@ -105,7 +101,7 @@ Transaction Exit Usage:
var txBytes, proof, confirmSignatures []byte
if viper.GetBool(useNodeF) { // query full node
var result *tm.ResultTx
result, confirmSignatures, err = getProof(ctx, addr, position)
result, confirmSignatures, err = getProof(position)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same with above

if err != nil {
return fmt.Errorf("failed to retrieve exit information: { %s }", err)
}
Expand Down
56 changes: 36 additions & 20 deletions cmd/plasmacli/subcmd/eth/prove.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package eth

import (
"encoding/json"
"fmt"
"github.com/FourthState/plasma-mvp-sidechain/cmd/plasmacli/config"
ks "github.com/FourthState/plasma-mvp-sidechain/cmd/plasmacli/store"
"github.com/FourthState/plasma-mvp-sidechain/plasma"
"github.com/FourthState/plasma-mvp-sidechain/store"
"github.com/cosmos/cosmos-sdk/client/context"
ethcmn "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rlp"
"github.com/spf13/cobra"
tm "github.com/tendermint/tendermint/rpc/core/types"
Expand All @@ -19,24 +18,18 @@ func ProveCmd() *cobra.Command {
}

var proveCmd = &cobra.Command{
Use: "prove <account> <position>",
Use: "prove <position>",
Short: "Prove transaction inclusion: prove <account> <position>",
Args: cobra.ExactArgs(2),
Long: "Returns proof for transaction inclusion. Use to exit transactions in the smart contract",
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.NewCLIContext()
addr, err := ks.GetAccount(args[0])
if err != nil {
return fmt.Errorf("failed to retrieve account: { %s }", err)
}

// parse position
position, err := plasma.FromPositionString(args[1])
if err != nil {
return err
}

result, sigs, err := getProof(ctx, addr, position)
result, sigs, err := getProof(position)
if err != nil {
return err
}
Expand Down Expand Up @@ -76,28 +69,51 @@ var proveCmd = &cobra.Command{

// Returns transaction results for given position
// Trusts connected full node
func getProof(ctx context.CLIContext, addr ethcmn.Address, position plasma.Position) (*tm.ResultTx, []byte, error) {
// query for the output
key := append(addr.Bytes(), position.Bytes()...)
res, err := ctx.QueryStore(key, "utxo")
func getProof(position plasma.Position) (*tm.ResultTx, []byte, error) {
ctx := context.NewCLIContext().WithTrustNode(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ctx should be a parameter and WithTrustNode should not be explicitly set. Trust-Node can be set via flag/commandline/env/config.toml

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can merge in my config PR first so that the changes are in effect before merging this into develop


key := store.GetOutputKey(position)
hash, err := ctx.QueryStore(key, "outputs")
if err != nil {
return &tm.ResultTx{}, nil, err
}

utxo := store.UTXO{}
if err := rlp.DecodeBytes(res, &utxo); err != nil {
return &tm.ResultTx{}, nil, err
txKey := store.GetTxKey(hash)
txBytes, err := ctx.QueryStore(txKey, "outputs")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about having each store define it's name instead of hardcoding the string?


var tx store.Transaction
if err := rlp.DecodeBytes(txBytes, &tx); err != nil {
return &tm.ResultTx{}, nil, fmt.Errorf("Transaction decoding failed: %s", err.Error())
}

// query tm node for information about this tx
result, err := ctx.Client.Tx(utxo.MerkleHash, true)
result, err := ctx.Client.Tx(tx.Transaction.MerkleHash(), true)
if err != nil {
return &tm.ResultTx{}, nil, err
}

// Look for confirmation signatures
key = append([]byte("confirmSignature"), utxo.Position.Bytes()...)
sigs, err := ctx.QueryStore(key, "plasma")
// Ignore error if no confirm sig currently exists in store
var sigs []byte
if len(tx.SpenderTxs[position.OutputIndex]) > 0 {
queryPath := fmt.Sprintf("custom/utxo/tx/%s", tx.SpenderTxs[position.OutputIndex])
data, err := ctx.Query(queryPath, nil)
if err != nil {
return &tm.ResultTx{}, nil, err
}

var spenderTx store.Transaction
if err := json.Unmarshal(data, &spenderTx); err != nil {
return &tm.ResultTx{}, nil, fmt.Errorf("unmarshaling json query response: %s", err)
}
for _, input := range spenderTx.Transaction.Inputs {
if input.Position.String() == position.String() {
for _, sig := range input.ConfirmSignatures {
sigs = append(sigs, sig[:]...)
}
}
}
}

return result, sigs, nil
}
4 changes: 2 additions & 2 deletions cmd/plasmacli/subcmd/eth/query/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ func DepositCmd() *cobra.Command {

var depositCmd = &cobra.Command{
Use: "deposit <nonce>",
Short: "Query for a deposit that occured on the rootchain",
Long: `Queries for deposits that occured on the rootchain.
Short: "Query for a deposit that occurred on the rootchain",
Long: `Queries for deposits that occurred on the rootchain.

Usage:
plasmacli eth query deposit <nonce>
Expand Down
2 changes: 1 addition & 1 deletion cmd/plasmacli/subcmd/eth/query/rootchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var rootchainCmd = &cobra.Command{
Use: "rootchain",
Short: "Display rootchain contract information",
Long: `Display last committed block, total contract balance, total withdraw balance, minimum exit bond, and operator address.
Total contract balance does not include total withdraw balance. The total withdraw balance are exits that have been finalized, but not transfered yet.`,
Total contract balance does not include total withdraw balance. The total withdraw balance are exits that have been finalized, but not transferred yet.`,
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, agrs []string) error {
lastCommittedBlock, err := plasmaContract.LastCommittedBlock(nil)
Expand Down
4 changes: 2 additions & 2 deletions cmd/plasmacli/subcmd/eth/withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ func WithdrawCmd() *cobra.Command {

var withdrawCmd = &cobra.Command{
Use: "withdraw <account>",
Short: "Withdraw all avaliable funds from rootchain contract",
Long: `Withdraw all avaliable funds from the rootchain contract
Short: "Withdraw all available funds from rootchain contract",
Long: `Withdraw all available funds from the rootchain contract

Usage:
plasmacli eth withdraw <account> --gas-limit 30000`,
Expand Down
27 changes: 11 additions & 16 deletions cmd/plasmacli/subcmd/query/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,23 @@ var infoCmd = &cobra.Command{
return err
}

var utxos []store.UTXO
var utxos []store.TxOutput
if err := json.Unmarshal(data, &utxos); err != nil {
return fmt.Errorf("unmarshaling json query response: %s", err)
}

for i, utxo := range utxos {
fmt.Printf("UTXO %d\n", i)
fmt.Printf("Position: %s, Amount: %s, Spent: %t\n", utxo.Position, utxo.Output.Amount.String(), utxo.Spent)

// print inputs if applicable
inputAddresses := utxo.InputAddresses()
positions := utxo.InputPositions()
for i, _ := range inputAddresses {
fmt.Printf("Input Owner %d, Position: %s\n", i, positions[i])
}

// print spenders if applicable
spenderAddresses := utxo.SpenderAddresses()
positions = utxo.SpenderPositions()
for i, _ := range spenderAddresses {
fmt.Printf("Spender Owner %d, Position: %s\n", i, positions[i])
}
fmt.Printf("Position: %s, Amount: %s, Spent: %t\nSpender Hash: %s\n", utxo.Position, utxo.Output.Amount.String(), utxo.Spent, utxo.SpenderTx)
fmt.Printf("Transaction Hash: 0x%x\nConfirmationHash: 0x%x\n", utxo.TxHash, utxo.ConfirmationHash)
/*
// TODO: Add --verbose flag that if set will query TxInput and print InputAddresses and InputPositions as well
// print inputs if applicable
positions := utxo.InputPositions
for i, p := range positions {
fmt.Printf("Input %d Position: %s\n", i, p)
}
*/

fmt.Printf("End UTXO %d info\n\n", i)
}
Expand Down
Loading