From 3f9c463a5179e497d884f3c4bccec7ae68041643 Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Wed, 2 Jun 2021 18:59:58 -0400 Subject: [PATCH 01/20] service_payment --- NOTES.md | 36 + cmd/thetacli/cmd/tx/main.go | 2 + cmd/thetacli/cmd/tx/reserve_fund.go | 2 +- cmd/thetacli/cmd/tx/service_payment.go | 152 ++++ tree.out | 1035 ++++++++++++++++++++++++ 5 files changed, 1226 insertions(+), 1 deletion(-) create mode 100644 NOTES.md create mode 100644 cmd/thetacli/cmd/tx/service_payment.go create mode 100644 tree.out diff --git a/NOTES.md b/NOTES.md new file mode 100644 index 00000000..153c8938 --- /dev/null +++ b/NOTES.md @@ -0,0 +1,36 @@ +``` +$ thetacli query account --address=2E833968E5bB786Ae419c4d13189fB081Cc43bab +Using config file: /Users/i830671/.thetacli/config.yaml +{ + "code": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "coins": { + "tfuelwei": "312499798999999000000000000", + "thetawei": "12500000000000000000000000" + }, + "last_updated_block_height": "0", + "reserved_funds": [ + { + "collateral": { + "tfuelwei": "101000000000000000000", + "thetawei": "0" + }, + "end_block_height": "1428", + "initial_fund": { + "tfuelwei": "100000000000000000000", + "thetawei": "0" + }, + "reserve_sequence": "1", + "resource_ids": [ + "rid1000001" + ], + "transfer_records": [], + "used_fund": { + "tfuelwei": "0", + "thetawei": "0" + } + } + ], + "root": "0x0000000000000000000000000000000000000000000000000000000000000000", + "sequence": "1" +} +``` \ No newline at end of file diff --git a/cmd/thetacli/cmd/tx/main.go b/cmd/thetacli/cmd/tx/main.go index 7bf756f7..372c6df2 100644 --- a/cmd/thetacli/cmd/tx/main.go +++ b/cmd/thetacli/cmd/tx/main.go @@ -21,6 +21,7 @@ var ( reserveFundInTFuelFlag string reserveCollateralInTFuelFlag string reserveSeqFlag uint64 + paymentSeqFlag uint64 addressesFlag []string percentagesFlag []string valueFlag string @@ -45,6 +46,7 @@ var TxCmd = &cobra.Command{ func init() { TxCmd.AddCommand(sendCmd) TxCmd.AddCommand(reserveFundCmd) + TxCmd.AddCommand(servicePaymentCmd) //TxCmd.AddCommand(releaseFundCmd) // No need for releaseFundCmd since auto-release is already implemented TxCmd.AddCommand(splitRuleCmd) TxCmd.AddCommand(smartContractCmd) diff --git a/cmd/thetacli/cmd/tx/reserve_fund.go b/cmd/thetacli/cmd/tx/reserve_fund.go index 632ef0b5..44106c16 100644 --- a/cmd/thetacli/cmd/tx/reserve_fund.go +++ b/cmd/thetacli/cmd/tx/reserve_fund.go @@ -106,7 +106,7 @@ func init() { reserveFundCmd.Flags().StringVar(&reserveCollateralInTFuelFlag, "collateral", "0", "TFuel amount as collateral") reserveFundCmd.Flags().StringVar(&feeFlag, "fee", fmt.Sprintf("%dwei", types.MinimumTransactionFeeTFuelWei), "Fee") reserveFundCmd.Flags().Uint64Var(&durationFlag, "duration", 1000, "Reserve duration") - reserveFundCmd.Flags().StringSliceVar(&resourceIDsFlag, "resource_ids", []string{}, "Reserouce IDs") + reserveFundCmd.Flags().StringSliceVar(&resourceIDsFlag, "resource_ids", []string{}, "Resource IDs") reserveFundCmd.Flags().StringVar(&walletFlag, "wallet", "soft", "Wallet type (soft|nano)") reserveFundCmd.MarkFlagRequired("chain") diff --git a/cmd/thetacli/cmd/tx/service_payment.go b/cmd/thetacli/cmd/tx/service_payment.go new file mode 100644 index 00000000..12813acd --- /dev/null +++ b/cmd/thetacli/cmd/tx/service_payment.go @@ -0,0 +1,152 @@ +package tx + +import ( + "encoding/hex" + "encoding/json" + "fmt" + "math/big" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + "github.com/thetatoken/theta/cmd/thetacli/cmd/utils" + "github.com/thetatoken/theta/common" + "github.com/thetatoken/theta/ledger/types" + "github.com/thetatoken/theta/rpc" + wtypes "github.com/thetatoken/theta/wallet/types" + + "github.com/ybbus/jsonrpc" + rpcc "github.com/ybbus/jsonrpc" +) + +// servicePaymentCmd represents the send command +// Example: +// thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=9F1233798E905E173560071255140b4A8aBd3Ec6 --payment_seq=1 --reserve_seq=1 --resource_id=rid1000001 +var servicePaymentCmd = &cobra.Command{ + Use: "service_payment", + Short: "Make Service Payment from Reserve fund", + Example: `thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=9F1233798E905E173560071255140b4A8aBd3Ec6 --payment_seq=1 --reserve_seq=1 --resource_id=rid1000001`, + Run: doServicePaymentCmd, +} + +func doServicePaymentCmd(cmd *cobra.Command, args []string) { + walletType := getWalletType(cmd) + if walletType == wtypes.WalletTypeSoft && len(fromFlag) == 0 { + utils.Error("The from address cannot be empty") // we don't need to specify the "from address" for hardware wallets + return + } + + if len(toFlag) == 0 { + utils.Error("The to address cannot be empty") + return + } + if fromFlag == toFlag { + utils.Error("The from and to address cannot be identical") + return + } + + wallet, fromAddress, err := walletUnlockWithPath(cmd, fromFlag, pathFlag) + if err != nil || wallet == nil { + return + } + defer wallet.Lock(fromAddress) + + fee, ok := types.ParseCoinAmount(feeFlag) + if !ok { + utils.Error("Failed to parse fee") + } + + sinput := types.TxInput{ + Address: fromAddress, + Coins: types.Coins{ + ThetaWei: new(big.Int).SetUint64(0), + TFuelWei: new(big.Int).SetUint64(0), + }, + Sequence: uint64(paymentSeqFlag), + } + + tinput := types.TxInput{ + Address: common.HexToAddress(toFlag), + Coins: types.Coins{ + ThetaWei: new(big.Int).SetUint64(0), + TFuelWei: new(big.Int).SetUint64(0), + }, + //Sequence: uint64(paymentSeqFlag), + } + + // See theta-protocol-ledger > ledger > types > tx.go : Line 522 + servicePaymentTx := &types.ServicePaymentTx{ + Fee: types.Coins{ + ThetaWei: new(big.Int).SetUint64(0), + TFuelWei: fee, + }, + Source: sinput, + Target: tinput, + PaymentSequence: paymentSeqFlag, + ReserveSequence: reserveSeqFlag, + ResourceID: resourceIDFlag, + } + + ssig, err := wallet.Sign(fromAddress, servicePaymentTx.SourceSignBytes(chainIDFlag)) + if err != nil { + utils.Error("Failed to sign source transaction: %v\n", err) + } + servicePaymentTx.SetSourceSignature(ssig) + + tsig, err := wallet.Sign(tinput.Address, servicePaymentTx.TargetSignBytes(chainIDFlag)) + if err != nil { + utils.Error("Failed to sign target transaction: %v\n", err) + } + servicePaymentTx.SetTargetSignature(tsig) + + raw, err := types.TxToBytes(servicePaymentTx) + if err != nil { + utils.Error("Failed to encode transaction: %v\n", err) + } + signedTx := hex.EncodeToString(raw) + + client := rpcc.NewRPCClient(viper.GetString(utils.CfgRemoteRPCEndpoint)) + + var res *jsonrpc.RPCResponse + if asyncFlag { + res, err = client.Call("theta.BroadcastRawTransactionAsync", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) + } else { + res, err = client.Call("theta.BroadcastRawTransaction", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) + } + + if err != nil { + utils.Error("Failed to broadcast transaction: %v\n", err) + } + if res.Error != nil { + utils.Error("Server returned error: %v\n", res.Error) + } + result := &rpc.BroadcastRawTransactionResult{} + err = res.GetObject(result) + if err != nil { + utils.Error("Failed to parse server response: %v\n", err) + } + formatted, err := json.MarshalIndent(result, "", " ") + if err != nil { + utils.Error("Failed to parse server response: %v\n", err) + } + fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) +} + +func init() { + servicePaymentCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") + servicePaymentCmd.Flags().StringVar(&fromFlag, "from", "", "Address to send from") + servicePaymentCmd.Flags().StringVar(&toFlag, "to", "", "Address to send to") + servicePaymentCmd.Flags().StringVar(&pathFlag, "path", "", "Wallet derivation path") + servicePaymentCmd.Flags().Uint64Var(&paymentSeqFlag, "payment_seq", 0, "Payment sequence number of the transaction") + servicePaymentCmd.Flags().Uint64Var(&reserveSeqFlag, "reserve_seq", 0, "Reserve sequence number of the transaction") + servicePaymentCmd.Flags().StringVar(&resourceIDFlag, "resource_id", "", "Corresponding resourceID") + servicePaymentCmd.Flags().StringVar(&feeFlag, "fee", fmt.Sprintf("%dwei", types.MinimumTransactionFeeTFuelWei), "Fee") + servicePaymentCmd.Flags().StringVar(&walletFlag, "wallet", "soft", "Wallet type (soft|nano|trezor)") + servicePaymentCmd.Flags().BoolVar(&asyncFlag, "async", false, "block until tx has been included in the blockchain") + + servicePaymentCmd.MarkFlagRequired("chain") + servicePaymentCmd.MarkFlagRequired("from") + servicePaymentCmd.MarkFlagRequired("to") + servicePaymentCmd.MarkFlagRequired("payment_seq") + servicePaymentCmd.MarkFlagRequired("reserve_seq") + servicePaymentCmd.MarkFlagRequired("resource_id") +} diff --git a/tree.out b/tree.out new file mode 100644 index 00000000..355b025f --- /dev/null +++ b/tree.out @@ -0,0 +1,1035 @@ +. +├── Dockerfile +├── LICENSE +├── Makefile +├── README.md +├── blockchain +│   ├── chain.go +│   ├── chain_test.go +│   ├── testutil.go +│   ├── tx.go +│   ├── tx_test.go +│   ├── util_test.go +│   ├── vote.go +│   └── vote_test.go +├── cmd +│   ├── theta +│   │   ├── cmd +│   │   │   ├── init.go +│   │   │   ├── root.go +│   │   │   ├── start.go +│   │   │   └── version.go +│   │   └── main.go +│   └── thetacli +│   ├── cmd +│   │   ├── backup +│   │   │   ├── chain.go +│   │   │   ├── correction.go +│   │   │   ├── main.go +│   │   │   └── snapshot.go +│   │   ├── call +│   │   │   ├── main.go +│   │   │   └── smart_contract.go +│   │   ├── daemon +│   │   │   ├── daemon.go +│   │   │   └── main.go +│   │   ├── key +│   │   │   ├── delete.go +│   │   │   ├── list.go +│   │   │   ├── main.go +│   │   │   ├── new.go +│   │   │   ├── password.go +│   │   │   └── recover.go +│   │   ├── query +│   │   │   ├── account.go +│   │   │   ├── block.go +│   │   │   ├── gcp.go +│   │   │   ├── guardian.go +│   │   │   ├── main.go +│   │   │   ├── peers.go +│   │   │   ├── split_rule.go +│   │   │   ├── status.go +│   │   │   ├── tx.go +│   │   │   ├── vcp.go +│   │   │   └── version.go +│   │   ├── root.go +│   │   ├── tx +│   │   │   ├── deposit_stake.go +│   │   │   ├── main.go +│   │   │   ├── release_fund.go +│   │   │   ├── reserve_fund.go +│   │   │   ├── send.go +│   │   │   ├── smart_contract.go +│   │   │   ├── split_rule.go +│   │   │   ├── utils.go +│   │   │   └── withdraw_stake.go +│   │   ├── utils +│   │   │   ├── config.go +│   │   │   └── utils.go +│   │   └── version.go +│   ├── main.go +│   └── rpc +│   ├── key.go +│   ├── server.go +│   └── tx.go +├── common +│   ├── async.go +│   ├── big.go +│   ├── bytes.go +│   ├── bytes_test.go +│   ├── clist +│   │   ├── clist.go +│   │   └── clist_test.go +│   ├── config.go +│   ├── go.mod +│   ├── go.sum +│   ├── heights.go +│   ├── hexutil +│   │   ├── hexutil.go +│   │   ├── hexutil_test.go +│   │   ├── json.go +│   │   ├── json_example_test.go +│   │   └── json_test.go +│   ├── json.go +│   ├── json_test.go +│   ├── math +│   │   ├── big.go +│   │   ├── big_test.go +│   │   ├── integer.go +│   │   ├── integer_test.go +│   │   └── minmax.go +│   ├── metrics +│   │   ├── FORK.md +│   │   ├── LICENSE +│   │   ├── README.md +│   │   ├── counter.go +│   │   ├── counter_test.go +│   │   ├── debug.go +│   │   ├── debug_test.go +│   │   ├── disk.go +│   │   ├── disk_linux.go +│   │   ├── disk_nop.go +│   │   ├── ewma.go +│   │   ├── ewma_test.go +│   │   ├── exp +│   │   │   └── exp.go +│   │   ├── gauge.go +│   │   ├── gauge_float64.go +│   │   ├── gauge_float64_test.go +│   │   ├── gauge_test.go +│   │   ├── graphite.go +│   │   ├── graphite_test.go +│   │   ├── healthcheck.go +│   │   ├── histogram.go +│   │   ├── histogram_test.go +│   │   ├── init_test.go +│   │   ├── json.go +│   │   ├── json_test.go +│   │   ├── librato +│   │   │   ├── client.go +│   │   │   └── librato.go +│   │   ├── log.go +│   │   ├── memory.md +│   │   ├── meter.go +│   │   ├── meter_test.go +│   │   ├── metrics.go +│   │   ├── metrics_test.go +│   │   ├── opentsdb.go +│   │   ├── opentsdb_test.go +│   │   ├── registry.go +│   │   ├── registry_test.go +│   │   ├── resetting_timer.go +│   │   ├── resetting_timer_test.go +│   │   ├── runtime.go +│   │   ├── runtime_cgo.go +│   │   ├── runtime_gccpufraction.go +│   │   ├── runtime_no_cgo.go +│   │   ├── runtime_no_gccpufraction.go +│   │   ├── runtime_test.go +│   │   ├── sample.go +│   │   ├── sample_test.go +│   │   ├── syslog.go +│   │   ├── timer.go +│   │   ├── timer_test.go +│   │   ├── validate.sh +│   │   ├── writer.go +│   │   └── writer_test.go +│   ├── os.go +│   ├── pqueue +│   │   ├── priority_queue.go +│   │   └── priority_queue_test.go +│   ├── result +│   │   ├── error_code.go +│   │   └── result.go +│   ├── timer +│   │   ├── repeat_timer.go +│   │   └── throttle_timer.go +│   ├── types.go +│   ├── types_test.go +│   └── util +│   ├── formatter.go +│   ├── ip.go +│   ├── log.go +│   ├── log_test.go +│   ├── misc.go +│   └── sample.go +├── consensus +│   ├── engine.go +│   ├── engine_test.go +│   ├── guardian.go +│   ├── guardian_test.go +│   ├── state.go +│   ├── state_test.go +│   ├── testutil.go +│   └── validator.go +├── core +│   ├── backup.go +│   ├── block.go +│   ├── block_test.go +│   ├── bloom.go +│   ├── consensus.go +│   ├── genesis.go +│   ├── guardian.go +│   ├── guardian_test.go +│   ├── hardcode_block_hashes.go +│   ├── ledger.go +│   ├── snapshot.go +│   ├── stake.go +│   ├── stake_test.go +│   ├── testutil.go +│   ├── validator.go +│   ├── validator_test.go +│   ├── vote.go +│   └── vote_test.go +├── crypto +│   ├── bls +│   │   ├── bls.go +│   │   ├── bls_benchmark_test.go +│   │   └── bls_test.go +│   ├── bn256 +│   │   ├── LICENSE +│   │   ├── bn256_fast.go +│   │   ├── bn256_fuzz.go +│   │   ├── bn256_slow.go +│   │   ├── cloudflare +│   │   │   ├── LICENSE +│   │   │   ├── bn256.go +│   │   │   ├── bn256_test.go +│   │   │   ├── constants.go +│   │   │   ├── curve.go +│   │   │   ├── example_test.go +│   │   │   ├── gfp.go +│   │   │   ├── gfp12.go +│   │   │   ├── gfp2.go +│   │   │   ├── gfp6.go +│   │   │   ├── gfp_amd64.s +│   │   │   ├── gfp_arm64.s +│   │   │   ├── gfp_decl.go +│   │   │   ├── gfp_generic.go +│   │   │   ├── gfp_test.go +│   │   │   ├── lattice.go +│   │   │   ├── lattice_test.go +│   │   │   ├── main_test.go +│   │   │   ├── mul_amd64.h +│   │   │   ├── mul_arm64.h +│   │   │   ├── mul_bmi2_amd64.h +│   │   │   ├── optate.go +│   │   │   └── twist.go +│   │   └── google +│   │   ├── bn256.go +│   │   ├── bn256_test.go +│   │   ├── constants.go +│   │   ├── curve.go +│   │   ├── example_test.go +│   │   ├── gfp12.go +│   │   ├── gfp2.go +│   │   ├── gfp6.go +│   │   ├── main_test.go +│   │   ├── optate.go +│   │   └── twist.go +│   ├── crypto.go +│   ├── crypto_test.go +│   ├── ecies +│   │   ├── LICENSE +│   │   ├── README +│   │   ├── ecies.go +│   │   ├── ecies_test.go +│   │   └── params.go +│   ├── keyutils.go +│   ├── keyutils_test.go +│   ├── secp256k1 +│   │   ├── LICENSE +│   │   ├── curve.go +│   │   ├── ext.h +│   │   ├── libsecp256k1 +│   │   │   ├── COPYING +│   │   │   ├── Makefile.am +│   │   │   ├── README.md +│   │   │   ├── TODO +│   │   │   ├── autogen.sh +│   │   │   ├── build-aux +│   │   │   │   └── m4 +│   │   │   │   ├── ax_jni_include_dir.m4 +│   │   │   │   ├── ax_prog_cc_for_build.m4 +│   │   │   │   └── bitcoin_secp.m4 +│   │   │   ├── configure.ac +│   │   │   ├── contrib +│   │   │   │   ├── lax_der_parsing.c +│   │   │   │   ├── lax_der_parsing.h +│   │   │   │   ├── lax_der_privatekey_parsing.c +│   │   │   │   └── lax_der_privatekey_parsing.h +│   │   │   ├── include +│   │   │   │   ├── secp256k1.h +│   │   │   │   ├── secp256k1_ecdh.h +│   │   │   │   └── secp256k1_recovery.h +│   │   │   ├── libsecp256k1.pc.in +│   │   │   ├── obj +│   │   │   ├── sage +│   │   │   │   ├── group_prover.sage +│   │   │   │   ├── secp256k1.sage +│   │   │   │   └── weierstrass_prover.sage +│   │   │   └── src +│   │   │   ├── asm +│   │   │   │   └── field_10x26_arm.s +│   │   │   ├── basic-config.h +│   │   │   ├── bench.h +│   │   │   ├── bench_ecdh.c +│   │   │   ├── bench_internal.c +│   │   │   ├── bench_recover.c +│   │   │   ├── bench_schnorr_verify.c +│   │   │   ├── bench_sign.c +│   │   │   ├── bench_verify.c +│   │   │   ├── ecdsa.h +│   │   │   ├── ecdsa_impl.h +│   │   │   ├── eckey.h +│   │   │   ├── eckey_impl.h +│   │   │   ├── ecmult.h +│   │   │   ├── ecmult_const.h +│   │   │   ├── ecmult_const_impl.h +│   │   │   ├── ecmult_gen.h +│   │   │   ├── ecmult_gen_impl.h +│   │   │   ├── ecmult_impl.h +│   │   │   ├── field.h +│   │   │   ├── field_10x26.h +│   │   │   ├── field_10x26_impl.h +│   │   │   ├── field_5x52.h +│   │   │   ├── field_5x52_asm_impl.h +│   │   │   ├── field_5x52_impl.h +│   │   │   ├── field_5x52_int128_impl.h +│   │   │   ├── field_impl.h +│   │   │   ├── gen_context.c +│   │   │   ├── group.h +│   │   │   ├── group_impl.h +│   │   │   ├── hash.h +│   │   │   ├── hash_impl.h +│   │   │   ├── java +│   │   │   │   ├── org +│   │   │   │   │   └── bitcoin +│   │   │   │   │   ├── NativeSecp256k1.java +│   │   │   │   │   ├── NativeSecp256k1Test.java +│   │   │   │   │   ├── NativeSecp256k1Util.java +│   │   │   │   │   └── Secp256k1Context.java +│   │   │   │   ├── org_bitcoin_NativeSecp256k1.c +│   │   │   │   ├── org_bitcoin_NativeSecp256k1.h +│   │   │   │   ├── org_bitcoin_Secp256k1Context.c +│   │   │   │   └── org_bitcoin_Secp256k1Context.h +│   │   │   ├── modules +│   │   │   │   ├── ecdh +│   │   │   │   │   ├── Makefile.am.include +│   │   │   │   │   ├── main_impl.h +│   │   │   │   │   └── tests_impl.h +│   │   │   │   └── recovery +│   │   │   │   ├── Makefile.am.include +│   │   │   │   ├── main_impl.h +│   │   │   │   └── tests_impl.h +│   │   │   ├── num.h +│   │   │   ├── num_gmp.h +│   │   │   ├── num_gmp_impl.h +│   │   │   ├── num_impl.h +│   │   │   ├── scalar.h +│   │   │   ├── scalar_4x64.h +│   │   │   ├── scalar_4x64_impl.h +│   │   │   ├── scalar_8x32.h +│   │   │   ├── scalar_8x32_impl.h +│   │   │   ├── scalar_impl.h +│   │   │   ├── scalar_low.h +│   │   │   ├── scalar_low_impl.h +│   │   │   ├── secp256k1.c +│   │   │   ├── testrand.h +│   │   │   ├── testrand_impl.h +│   │   │   ├── tests.c +│   │   │   ├── tests_exhaustive.c +│   │   │   └── util.h +│   │   ├── panic_cb.go +│   │   ├── secp256.go +│   │   └── secp256_test.go +│   ├── sha3 +│   │   ├── LICENSE +│   │   ├── PATENTS +│   │   ├── doc.go +│   │   ├── hashes.go +│   │   ├── keccakf.go +│   │   ├── keccakf_amd64.go +│   │   ├── keccakf_amd64.s +│   │   ├── register.go +│   │   ├── sha3.go +│   │   ├── sha3_test.go +│   │   ├── shake.go +│   │   ├── testdata +│   │   │   └── keccakKats.json.deflate +│   │   ├── xor.go +│   │   ├── xor_generic.go +│   │   └── xor_unaligned.go +│   ├── signatureutils.go +│   ├── signatureutils_test.go +│   └── testutils.go +├── dispatcher +│   ├── dispatcher.go +│   └── types.go +├── docs +│   ├── commands +│   │   ├── generator.exe +│   │   ├── generator.go +│   │   ├── ledger +│   │   │   ├── theta.md +│   │   │   ├── theta_init.md +│   │   │   ├── theta_start.md +│   │   │   └── theta_version.md +│   │   ├── walker.go +│   │   └── wallet +│   │   ├── thetacli.md +│   │   ├── thetacli_backup.md +│   │   ├── thetacli_backup_chain.md +│   │   ├── thetacli_backup_snapshot.md +│   │   ├── thetacli_call.md +│   │   ├── thetacli_call_smart_contract.md +│   │   ├── thetacli_daemon.md +│   │   ├── thetacli_daemon_start.md +│   │   ├── thetacli_key.md +│   │   ├── thetacli_key_delete.md +│   │   ├── thetacli_key_list.md +│   │   ├── thetacli_key_new.md +│   │   ├── thetacli_key_password.md +│   │   ├── thetacli_query.md +│   │   ├── thetacli_query_account.md +│   │   ├── thetacli_query_block.md +│   │   ├── thetacli_query_split_rule.md +│   │   ├── thetacli_query_status.md +│   │   ├── thetacli_query_tx.md +│   │   ├── thetacli_query_vcp.md +│   │   ├── thetacli_query_version.md +│   │   ├── thetacli_tx.md +│   │   ├── thetacli_tx_deposit.md +│   │   ├── thetacli_tx_reserve.md +│   │   ├── thetacli_tx_send.md +│   │   ├── thetacli_tx_smart_contract.md +│   │   ├── thetacli_tx_split_rule.md +│   │   └── thetacli_tx_withdraw.md +│   ├── multi-level-bft-tech-report.pdf +│   └── theta-technical-whitepaper.pdf +├── glide.lock +├── glide.yaml +├── go.mod +├── go.sum +├── integration +│   ├── build +│   │   └── build.sh +│   ├── docker +│   │   ├── build +│   │   │   ├── Dockerfile +│   │   │   ├── README.md +│   │   │   ├── build.sh +│   │   │   └── start.sh +│   │   └── node +│   │   ├── Dockerfile +│   │   ├── README.md +│   │   ├── build.sh +│   │   └── start.sh +│   ├── e2etest +│   │   └── eth_keypair_compatibility_test +│   │   ├── batch_test.py +│   │   └── new_account_password.txt +│   ├── mainnet +│   │   ├── validator +│   │   │   ├── config.yaml +│   │   │   ├── genesis +│   │   │   └── snapshot +│   │   └── walletnode +│   │   ├── config.yaml +│   │   ├── genesis +│   │   └── snapshot +│   ├── privatenet +│   │   ├── node +│   │   │   ├── config.yaml +│   │   │   ├── data +│   │   │   │   ├── genesis_signatures.json +│   │   │   │   ├── genesis_stake_deposit.json +│   │   │   │   ├── genesis_theta_erc20_snapshot.json +│   │   │   │   └── theta-balance-height-7160047.json +│   │   │   ├── genesis +│   │   │   ├── genesis.bak +│   │   │   ├── key +│   │   │   │   └── encrypted +│   │   │   │   └── 2E833968E5bB786Ae419c4d13189fB081Cc43bab +│   │   │   └── snapshot +│   │   └── thetacli +│   │   └── keys +│   │   ├── encrypted +│   │   │   ├── 0d2fD67d573c8ecB4161510fc00754d64B401F86 +│   │   │   ├── 21cA457E6E34162654aDEe28bcf235ebE5eee5De +│   │   │   ├── 2E833968E5bB786Ae419c4d13189fB081Cc43bab +│   │   │   ├── 70f587259738cB626A1720Af7038B8DcDb6a42a0 +│   │   │   ├── a5cdB2B0306518fb37b28bb63A1B2590FdE9b747 +│   │   │   └── cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 +│   │   └── plain +│   │   ├── 0d2fD67d573c8ecB4161510fc00754d64B401F86 +│   │   ├── 21cA457E6E34162654aDEe28bcf235ebE5eee5De +│   │   ├── 2E833968E5bB786Ae419c4d13189fB081Cc43bab +│   │   ├── 70f587259738cB626A1720Af7038B8DcDb6a42a0 +│   │   ├── a5cdB2B0306518fb37b28bb63A1B2590FdE9b747 +│   │   └── cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 +│   ├── testnet +│   │   ├── README.md +│   │   ├── extra +│   │   │   └── 7validators +│   │   │   ├── node5 +│   │   │   │   ├── config.yaml +│   │   │   │   ├── genesis +│   │   │   │   ├── key +│   │   │   │   │   └── encrypted +│   │   │   │   │   └── 5F74E3D5cc77b66F0030C5501CFBd39dcB8fF5b6 +│   │   │   │   ├── key.plain +│   │   │   │   └── snapshot +│   │   │   ├── node6 +│   │   │   │   ├── config.yaml +│   │   │   │   ├── genesis +│   │   │   │   ├── key +│   │   │   │   │   └── encrypted +│   │   │   │   │   └── DfB095B990C98A96dD434fe45Cd040EC2167C228 +│   │   │   │   ├── key.plain +│   │   │   │   └── snapshot +│   │   │   └── node7 +│   │   │   ├── config.yaml +│   │   │   ├── genesis +│   │   │   ├── key +│   │   │   │   └── encrypted +│   │   │   │   └── 350ddEf232565b32E66A9fB69780E85b686A9E1d +│   │   │   ├── key.plain +│   │   │   └── snapshot +│   │   ├── node1 +│   │   │   ├── addrbook.json +│   │   │   ├── addrbook.json.bak +│   │   │   ├── config.yaml +│   │   │   ├── data +│   │   │   │   ├── genesis_stake_deposit.json +│   │   │   │   ├── genesis_theta_erc20_snapshot.json +│   │   │   │   ├── genesis_theta_erc20_snapshot_basic.json +│   │   │   │   └── theta-balance-height-7160047.json +│   │   │   ├── genesis +│   │   │   ├── genesis.bak +│   │   │   ├── key +│   │   │   │   └── encrypted +│   │   │   │   └── 9F1233798E905E173560071255140b4A8aBd3Ec6 +│   │   │   ├── key.plain +│   │   │   └── snapshot +│   │   ├── node2 +│   │   │   ├── addrbook.json +│   │   │   ├── addrbook.json.bak +│   │   │   ├── config.yaml +│   │   │   ├── genesis +│   │   │   ├── genesis.bak +│   │   │   ├── key +│   │   │   │   └── encrypted +│   │   │   │   └── 2E833968E5bB786Ae419c4d13189fB081Cc43bab +│   │   │   ├── key.plain +│   │   │   └── snapshot +│   │   ├── node3 +│   │   │   ├── addrbook.json +│   │   │   ├── addrbook.json.bak +│   │   │   ├── config.yaml +│   │   │   ├── genesis +│   │   │   ├── genesis.bak +│   │   │   ├── key +│   │   │   │   └── encrypted +│   │   │   │   └── C15E24083152dD76Ae6FC2aEb5269FF23d70330B +│   │   │   ├── key.plain +│   │   │   └── snapshot +│   │   ├── node4 +│   │   │   ├── addrbook.json +│   │   │   ├── addrbook.json.bak +│   │   │   ├── config.yaml +│   │   │   ├── genesis +│   │   │   ├── genesis.bak +│   │   │   ├── key +│   │   │   │   └── encrypted +│   │   │   │   └── 7631958d57Cf6a5605635a5F06Aa2ae2e000820e +│   │   │   ├── key.plain +│   │   │   └── snapshot +│   │   ├── thetacli +│   │   │   └── keys +│   │   │   ├── encrypted +│   │   │   │   ├── 0d2fD67d573c8ecB4161510fc00754d64B401F86 +│   │   │   │   ├── 21cA457E6E34162654aDEe28bcf235ebE5eee5De +│   │   │   │   ├── 2E833968E5bB786Ae419c4d13189fB081Cc43bab +│   │   │   │   ├── 70f587259738cB626A1720Af7038B8DcDb6a42a0 +│   │   │   │   ├── a5cdB2B0306518fb37b28bb63A1B2590FdE9b747 +│   │   │   │   └── cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 +│   │   │   └── plain +│   │   │   ├── 0d2fD67d573c8ecB4161510fc00754d64B401F86 +│   │   │   ├── 21cA457E6E34162654aDEe28bcf235ebE5eee5De +│   │   │   ├── 2E833968E5bB786Ae419c4d13189fB081Cc43bab +│   │   │   ├── 70f587259738cB626A1720Af7038B8DcDb6a42a0 +│   │   │   ├── a5cdB2B0306518fb37b28bb63A1B2590FdE9b747 +│   │   │   └── cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 +│   │   └── walletnode +│   │   ├── config.yaml +│   │   ├── genesis +│   │   └── snapshot +│   ├── testnet_amber +│   │   ├── genesis_stake_deposit.json +│   │   ├── genesis_token_distribution.json +│   │   └── node +│   │   ├── config.yaml +│   │   └── snapshot +│   ├── testnet_sapphire +│   │   └── node +│   │   ├── config.yaml +│   │   └── snapshot +│   └── tools +│   ├── dump_storeview +│   │   └── dump_storeview.go +│   ├── encrypt_sk +│   │   └── encrypt_sk.go +│   ├── generate_genesis +│   │   └── generate_genesis.go +│   ├── hex_obj_parser +│   │   └── hex_obj_parser.go +│   ├── import_chain +│   │   └── import_chain.go +│   ├── inspect_data +│   │   └── inspect_data.go +│   ├── query_db +│   │   └── query_db.go +│   └── sign_hex_msg +│   └── sign_hex_msg.go +├── ledger +│   ├── execution +│   │   ├── executils.go +│   │   ├── executor.go +│   │   ├── regular_tx_execution_test.go +│   │   ├── smart_contract_tx_execution_test.go +│   │   ├── testdata +│   │   │   └── custom_token_transfer.json +│   │   ├── testutils.go +│   │   ├── tx_coinbase.go +│   │   ├── tx_deposit_stake.go +│   │   ├── tx_release_fund.go +│   │   ├── tx_reserve_fund.go +│   │   ├── tx_send.go +│   │   ├── tx_service_payment.go +│   │   ├── tx_slash.go +│   │   ├── tx_smart_contract.go +│   │   ├── tx_split_rule.go +│   │   └── tx_withdraw_stake.go +│   ├── ledger.go +│   ├── ledger_test.go +│   ├── state +│   │   ├── keys.go +│   │   ├── state.go +│   │   ├── state_test.go +│   │   ├── storeview.go +│   │   └── storeview_test.go +│   ├── testutils.go +│   ├── types +│   │   ├── account.go +│   │   ├── account_test.go +│   │   ├── coin.go +│   │   ├── coin_test.go +│   │   ├── const.go +│   │   ├── height_list.go +│   │   ├── height_list_test.go +│   │   ├── log.go +│   │   ├── log_test.go +│   │   ├── reserved_fund.go +│   │   ├── reserved_fund_test.go +│   │   ├── serialization.go +│   │   ├── serialization_test.go +│   │   ├── slash_intent.go +│   │   ├── slash_intent_test.go +│   │   ├── split_rule.go +│   │   ├── split_rule_test.go +│   │   ├── testutils.go +│   │   ├── tx.go +│   │   └── tx_test.go +│   └── vm +│   ├── analysis.go +│   ├── analysis_test.go +│   ├── asm +│   │   ├── asm.go +│   │   ├── asm_test.go +│   │   ├── compiler.go +│   │   ├── lex_test.go +│   │   └── lexer.go +│   ├── common.go +│   ├── contract.go +│   ├── contracts.go +│   ├── contracts_test.go +│   ├── doc.go +│   ├── errors.go +│   ├── exec.go +│   ├── exec_test.go +│   ├── gas.go +│   ├── gas_table.go +│   ├── gas_table_test.go +│   ├── gen_structlog.go +│   ├── instructions.go +│   ├── instructions_test.go +│   ├── int_pool_verifier.go +│   ├── int_pool_verifier_empty.go +│   ├── interface.go +│   ├── interpreter.go +│   ├── intpool.go +│   ├── intpool_test.go +│   ├── jump_table.go +│   ├── logger.go +│   ├── logger_test.go +│   ├── memory.go +│   ├── memory_table.go +│   ├── opcodes.go +│   ├── params +│   │   ├── bootnodes.go +│   │   ├── config.go +│   │   ├── dao.go +│   │   ├── denomination.go +│   │   ├── gas_table.go +│   │   ├── network_params.go +│   │   ├── protocol_params.go +│   │   └── version.go +│   ├── stack.go +│   ├── stack_table.go +│   ├── testdata +│   │   ├── erc20_token.json +│   │   ├── square_calculator.json +│   │   └── time_locked_safe.json +│   ├── vm.go +│   └── vm_test.go +├── mempool +│   ├── mempool.go +│   ├── mempool_message_handler.go +│   ├── mempool_message_handler_test.go +│   ├── mempool_test.go +│   ├── tx_bookkeeper.go +│   └── tx_bookkeeper_test.go +├── netsync +│   ├── encode.go +│   ├── encode_test.go +│   ├── request.go +│   ├── sync.go +│   └── sync_test.go +├── node +│   ├── node.go +│   └── node_test.go +├── p2p +│   ├── connection +│   │   ├── auth.go +│   │   ├── channel.go +│   │   ├── channel_group.go +│   │   ├── channel_group_test.go +│   │   ├── channel_test.go +│   │   ├── connection.go +│   │   ├── connection_test.go +│   │   ├── flowrate +│   │   │   ├── README.md +│   │   │   ├── flowrate.go +│   │   │   ├── io.go +│   │   │   ├── io_test.go +│   │   │   └── util.go +│   │   ├── packet.go +│   │   ├── packet_test.go +│   │   ├── recv_buffer.go +│   │   ├── recv_buffer_test.go +│   │   ├── send_buffer.go +│   │   └── send_buffer_test.go +│   ├── interface.go +│   ├── messenger +│   │   ├── addr_book.go +│   │   ├── addr_book_test.go +│   │   ├── disc_inbound_peer_listener.go +│   │   ├── disc_peer_discovery_message_handler.go +│   │   ├── disc_peer_discovery_message_handler_test.go +│   │   ├── disc_peer_no_response_test.go +│   │   ├── disc_seed_peer_connector.go +│   │   ├── discovery.go +│   │   ├── discovery_test.go +│   │   ├── messenger.go +│   │   ├── messenger_test.go +│   │   ├── nat_manager.go +│   │   └── nat_manager_test.go +│   ├── nat +│   │   ├── LICENSE +│   │   ├── README.md +│   │   ├── nat.go +│   │   ├── natpmp.go +│   │   └── upnp.go +│   ├── netutil +│   │   ├── net_addr.go +│   │   ├── net_addr_test.go +│   │   └── upnp.go +│   ├── peer +│   │   ├── peer.go +│   │   ├── peer_table.go +│   │   ├── peer_table_test.go +│   │   └── peer_test.go +│   ├── simulation +│   │   ├── simnet.go +│   │   └── simnet_test.go +│   └── types +│   ├── testutils.go +│   ├── types.go +│   └── types_test.go +├── p2pl +│   ├── common +│   │   └── common.go +│   ├── interface.go +│   ├── messenger +│   │   ├── disc_notifee.go +│   │   ├── messenger.go +│   │   ├── messenger_test.go +│   │   └── notify.go +│   ├── peer +│   │   ├── peer.go +│   │   └── peer_table.go +│   └── transport +│   ├── buffer +│   │   ├── chunk.go +│   │   ├── flowrate +│   │   │   ├── README.md +│   │   │   ├── flowrate.go +│   │   │   ├── io.go +│   │   │   ├── io_test.go +│   │   │   └── util.go +│   │   ├── recv_buffer.go +│   │   └── send_buffer.go +│   └── stream.go +├── report +│   └── reporter.go +├── rlp +│   ├── decode.go +│   ├── decode_tail_test.go +│   ├── decode_test.go +│   ├── doc.go +│   ├── encode.go +│   ├── encode_test.go +│   ├── encoder_example_test.go +│   ├── raw.go +│   ├── raw_test.go +│   └── typecache.go +├── rpc +│   ├── backup.go +│   ├── call.go +│   ├── client.go +│   ├── lib +│   │   └── rpc-codec +│   │   ├── LICENSE +│   │   ├── README.md +│   │   ├── go.mod +│   │   └── jsonrpc2 +│   │   ├── TODO +│   │   ├── all_test.go +│   │   ├── batch.go +│   │   ├── bench_test.go +│   │   ├── client.go +│   │   ├── context.go +│   │   ├── context_test.go +│   │   ├── doc.go +│   │   ├── errors.go +│   │   ├── example_test.go +│   │   ├── go.mod +│   │   ├── http.go +│   │   ├── http_test.go +│   │   ├── protocol_test.go +│   │   └── server.go +│   ├── query.go +│   ├── server.go +│   ├── tx.go +│   └── tx_test.go +├── snapshot +│   ├── chain_correction_export.go +│   ├── chain_export.go +│   ├── snapshot_export.go +│   └── snapshot_import.go +├── store +│   ├── database +│   │   ├── backend +│   │   │   ├── aerospike.go +│   │   │   ├── aerospike_test.go +│   │   │   ├── badgerdb.go +│   │   │   ├── badgerdb_test.go +│   │   │   ├── leveldb.go +│   │   │   ├── leveldb_test.go +│   │   │   ├── memdb.go +│   │   │   ├── memdb_test.go +│   │   │   ├── mgodb.go +│   │   │   ├── mgodb_test.go +│   │   │   ├── mongodb.go +│   │   │   └── mongodb_test.go +│   │   └── interface.go +│   ├── errors.go +│   ├── interface.go +│   ├── kvstore +│   │   ├── kvstore.go +│   │   └── kvstore_test.go +│   ├── treestore +│   │   ├── treestore.go +│   │   └── treestore_test.go +│   └── trie +│   ├── database.go +│   ├── encoding.go +│   ├── encoding_test.go +│   ├── errors.go +│   ├── hasher.go +│   ├── iterator.go +│   ├── iterator_test.go +│   ├── node.go +│   ├── node_test.go +│   ├── proof.go +│   ├── proof_test.go +│   ├── secure_trie.go +│   ├── secure_trie_test.go +│   ├── size.go +│   ├── size_test.go +│   ├── sync.go +│   ├── sync_test.go +│   ├── trie.go +│   └── trie_test.go +├── tree.out +├── version +│   └── version_number.txt +└── wallet + ├── coldwallet + │   ├── coldwallet.go + │   ├── coldwallet_test.go + │   ├── hid + │   │   ├── LICENSE.md + │   │   ├── README.md + │   │   ├── appveyor.yml + │   │   ├── go.mod + │   │   ├── hid.go + │   │   ├── hid_disabled.go + │   │   ├── hid_enabled.go + │   │   ├── hid_test.go + │   │   ├── hidapi + │   │   │   ├── AUTHORS.txt + │   │   │   ├── LICENSE-bsd.txt + │   │   │   ├── LICENSE-gpl3.txt + │   │   │   ├── LICENSE-orig.txt + │   │   │   ├── LICENSE.txt + │   │   │   ├── README.txt + │   │   │   ├── hidapi + │   │   │   │   └── hidapi.h + │   │   │   ├── libusb + │   │   │   │   └── hid.c + │   │   │   ├── mac + │   │   │   │   └── hid.c + │   │   │   └── windows + │   │   │   └── hid.c + │   │   ├── libusb + │   │   │   ├── AUTHORS + │   │   │   ├── COPYING + │   │   │   └── libusb + │   │   │   ├── config.h + │   │   │   ├── core.c + │   │   │   ├── descriptor.c + │   │   │   ├── hotplug.c + │   │   │   ├── hotplug.h + │   │   │   ├── io.c + │   │   │   ├── libusb.h + │   │   │   ├── libusbi.h + │   │   │   ├── os + │   │   │   │   ├── darwin_usb.c + │   │   │   │   ├── darwin_usb.h + │   │   │   │   ├── haiku_pollfs.cpp + │   │   │   │   ├── haiku_usb.h + │   │   │   │   ├── haiku_usb_backend.cpp + │   │   │   │   ├── haiku_usb_raw.cpp + │   │   │   │   ├── haiku_usb_raw.h + │   │   │   │   ├── linux_netlink.c + │   │   │   │   ├── linux_udev.c + │   │   │   │   ├── linux_usbfs.c + │   │   │   │   ├── linux_usbfs.h + │   │   │   │   ├── netbsd_usb.c + │   │   │   │   ├── openbsd_usb.c + │   │   │   │   ├── poll_posix.c + │   │   │   │   ├── poll_posix.h + │   │   │   │   ├── poll_windows.c + │   │   │   │   ├── poll_windows.h + │   │   │   │   ├── sunos_usb.c + │   │   │   │   ├── sunos_usb.h + │   │   │   │   ├── threads_posix.c + │   │   │   │   ├── threads_posix.h + │   │   │   │   ├── threads_windows.c + │   │   │   │   ├── threads_windows.h + │   │   │   │   ├── wince_usb.c + │   │   │   │   ├── wince_usb.h + │   │   │   │   ├── windows_common.h + │   │   │   │   ├── windows_nt_common.c + │   │   │   │   ├── windows_nt_common.h + │   │   │   │   ├── windows_usbdk.c + │   │   │   │   ├── windows_usbdk.h + │   │   │   │   ├── windows_winusb.c + │   │   │   │   └── windows_winusb.h + │   │   │   ├── strerror.c + │   │   │   ├── sync.c + │   │   │   ├── version.h + │   │   │   └── version_nano.h + │   │   ├── wchar.go + │   │   └── wchar_test.go + │   ├── keystore + │   │   ├── driver.go + │   │   ├── nano_ledger.go + │   │   ├── trezor + │   │   │   ├── messages.pb.go + │   │   │   ├── messages.proto + │   │   │   ├── protobuf.go + │   │   │   ├── transport.go + │   │   │   ├── trezor.go + │   │   │   ├── types.pb.go + │   │   │   ├── types.proto + │   │   │   └── ui.go + │   │   └── trezor.go + │   └── usb_hub.go + ├── softwallet + │   ├── keystore + │   │   ├── key.go + │   │   ├── keystore.go + │   │   ├── ks_encrypted.go + │   │   ├── ks_encrypted_test.go + │   │   ├── ks_plain.go + │   │   ├── ks_plain_test.go + │   │   ├── testdata + │   │   │   ├── dupes + │   │   │   │   ├── 1 + │   │   │   │   ├── 2 + │   │   │   │   └── foo + │   │   │   ├── keystore + │   │   │   │   ├── README + │   │   │   │   ├── UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8 + │   │   │   │   ├── aaa + │   │   │   │   ├── empty + │   │   │   │   ├── foo + │   │   │   │   │   └── fd9bd350f08ee3c0c19b85a8e16114a11a60aa4e + │   │   │   │   ├── garbage + │   │   │   │   ├── no-address + │   │   │   │   ├── zero + │   │   │   │   └── zzz + │   │   │   ├── test_vector.json + │   │   │   └── very-light-scrypt.json + │   │   └── testutils.go + │   ├── softwallet.go + │   └── softwallet_test.go + ├── types + │   ├── derivation_path.go + │   └── wallet.go + └── wallet.go + +180 directories, 852 files From 2f78e8f22bd5bc31be5ba9a7c5c36614f63bd419 Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Thu, 3 Jun 2021 19:00:07 -0400 Subject: [PATCH 02/20] wallet pain --- NOTES.md | 106 ++++++++++++++++++++- cmd/thetacli/cmd/tx/main.go | 2 + cmd/thetacli/cmd/tx/reserve_fund.go | 26 ++++- cmd/thetacli/cmd/tx/service_payment.go | 125 +++++++++++++++++-------- 4 files changed, 215 insertions(+), 44 deletions(-) diff --git a/NOTES.md b/NOTES.md index 153c8938..0726d89b 100644 --- a/NOTES.md +++ b/NOTES.md @@ -33,4 +33,108 @@ Using config file: /Users/i830671/.thetacli/config.yaml "root": "0x0000000000000000000000000000000000000000000000000000000000000000", "sequence": "1" } -``` \ No newline at end of file +``` +// From unit tests +// theta-protocol-ledger > ledger > execution > regular_ty_execution_test.go : Line 723 + + +func TestServicePaymentTxNormalExecutionAndSlash(t *testing.T) { + assert := assert.New(t) + + // This sets up 3 accounts with alice reserving funds on hers + et, resourceID, alice, bob, carol, _, bobInitBalance, carolInitBalance := setupForServicePayment(assert) + et.state().Commit() + + txFee := getMinimumTxFee() + +// Query Alices' account make sure she has a single reserve fund + retrievedAliceAcc0 := et.state().Delivered().GetAccount(alice.Address) + assert.Equal(1, len(retrievedAliceAcc0.ReservedFunds)) + assert.Equal([]string{resourceID}, retrievedAliceAcc0.ReservedFunds[0].ResourceIDs) + assert.Equal(types.Coins{TFuelWei: big.NewInt(1001 * txFee), ThetaWei: big.NewInt(0)}, retrievedAliceAcc0.ReservedFunds[0].Collateral) + assert.Equal(uint64(1), retrievedAliceAcc0.ReservedFunds[0].ReserveSequence) + + // Simulate micropayment #1 between Alice and Bob + payAmount1 := int64(80 * txFee) + srcSeq, tgtSeq, paymentSeq, reserveSeq := 1, 1, 1, 1 + _ = createServicePaymentTx(et.chainID, &alice, &bob, 10*txFee, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) + _ = createServicePaymentTx(et.chainID, &alice, &bob, 50*txFee, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) + + servicePaymentTx1 := createServicePaymentTx(et.chainID, &alice, &bob, payAmount1, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) + + res := et.executor.getTxExecutor(servicePaymentTx1).sanityCheck(et.chainID, et.state().Delivered(), servicePaymentTx1) + + assert.True(res.IsOK(), res.Message) + _, res = et.executor.getTxExecutor(servicePaymentTx1).process(et.chainID, et.state().Delivered(), servicePaymentTx1) + + assert.True(res.IsOK(), res.Message) + assert.Equal(0, len(et.state().Delivered().GetSlashIntents())) + + et.state().Commit() + + retrievedAliceAcc1 := et.state().Delivered().GetAccount(alice.Address) + + assert.Equal(types.Coins{TFuelWei: big.NewInt(payAmount1), ThetaWei: big.NewInt(0)}, retrievedAliceAcc1.ReservedFunds[0].UsedFund) + retrievedBobAcc1 := et.state().Delivered().GetAccount(bob.Address) + assert.Equal(bobInitBalance.Plus(types.Coins{TFuelWei: big.NewInt(payAmount1 - txFee), ThetaWei: big.NewInt(0)}), retrievedBobAcc1.Balance) // payAmount1 - txFee: need to account for tx fee + + // Simulate micropayment #2 between Alice and Bob + payAmount2 := int64(50 * txFee) + srcSeq, tgtSeq, paymentSeq, reserveSeq = 1, 2, 2, 1 + _ = createServicePaymentTx(et.chainID, &alice, &bob, 30*txFee, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) + servicePaymentTx2 := createServicePaymentTx(et.chainID, &alice, &bob, payAmount2, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) + res = et.executor.getTxExecutor(servicePaymentTx2).sanityCheck(et.chainID, et.state().Delivered(), servicePaymentTx2) + assert.True(res.IsOK(), res.Message) + _, res = et.executor.getTxExecutor(servicePaymentTx2).process(et.chainID, et.state().Delivered(), servicePaymentTx2) + assert.True(res.IsOK(), res.Message) + assert.Equal(0, len(et.state().Delivered().GetSlashIntents())) + + et.state().Commit() + + retrievedAliceAcc2 := et.state().Delivered().GetAccount(alice.Address) + assert.Equal(types.Coins{TFuelWei: big.NewInt(payAmount1 + payAmount2), ThetaWei: big.NewInt(0)}, retrievedAliceAcc2.ReservedFunds[0].UsedFund) + retrievedBobAcc2 := et.state().Delivered().GetAccount(bob.Address) + assert.Equal(bobInitBalance.Plus(types.Coins{TFuelWei: big.NewInt(payAmount1 + payAmount2 - 2*txFee)}), retrievedBobAcc2.Balance) // payAmount1 + payAmount2 - 2*txFee: need to account for tx fee + + // Simulate micropayment #3 between Alice and Carol + payAmount3 := int64(120 * txFee) + srcSeq, tgtSeq, paymentSeq, reserveSeq = 1, 1, 3, 1 + _ = createServicePaymentTx(et.chainID, &alice, &carol, 30*txFee, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) + servicePaymentTx3 := createServicePaymentTx(et.chainID, &alice, &carol, payAmount3, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) + res = et.executor.getTxExecutor(servicePaymentTx3).sanityCheck(et.chainID, et.state().Delivered(), servicePaymentTx3) + assert.True(res.IsOK(), res.Message) + _, res = et.executor.getTxExecutor(servicePaymentTx3).process(et.chainID, et.state().Delivered(), servicePaymentTx3) + assert.True(res.IsOK(), res.Message) + assert.Equal(0, len(et.state().Delivered().GetSlashIntents())) + + et.state().Commit() + + retrievedAliceAcc3 := et.state().Delivered().GetAccount(alice.Address) + assert.Equal(types.Coins{TFuelWei: big.NewInt(payAmount1 + payAmount2 + payAmount3), ThetaWei: big.NewInt(0)}, retrievedAliceAcc3.ReservedFunds[0].UsedFund) + retrievedCarolAcc3 := et.state().Delivered().GetAccount(carol.Address) + assert.Equal(carolInitBalance.Plus(types.Coins{TFuelWei: big.NewInt(payAmount3 - txFee)}), retrievedCarolAcc3.Balance) // payAmount3 - txFee: need to account for tx fee + + // Simulate micropayment #4 between Alice and Carol. This is an overspend, alice should get slashed. + payAmount4 := int64(2000 * txFee) + srcSeq, tgtSeq, paymentSeq, reserveSeq = 1, 2, 4, 1 + _ = createServicePaymentTx(et.chainID, &alice, &carol, 70000*txFee, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) + servicePaymentTx4 := createServicePaymentTx(et.chainID, &alice, &carol, payAmount4, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) + res = et.executor.getTxExecutor(servicePaymentTx4).sanityCheck(et.chainID, et.state().Delivered(), servicePaymentTx4) + assert.True(res.IsOK(), res.Message) // the following process() call will create an SlashIntent + + assert.Equal(0, len(et.state().Delivered().GetSlashIntents())) + _, res = et.executor.getTxExecutor(servicePaymentTx4).process(et.chainID, et.state().Delivered(), servicePaymentTx4) + assert.True(res.IsOK(), res.Message) + //assert.Equal(1, len(et.state().Delivered().GetSlashIntents())) + + + +thetacli tx reserve --async --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --fund=10 --collateral=11 --duration=1001 --resource_ids=rid1000001 --seq=1 + +"hash": "0x711e0001d454a556f6f1408f23f263fd2023c4c0e8eb54f5add1aaac137c8370", + +thetacli query tx --hash=711e0001d454a556f6f1408f23f263fd2023c4c0e8eb54f5add1aaac137c8370 + +thetacli tx service_payment --on_chain --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=2 --resource_id=rid1000001 + +thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=2 --resource_id=rid1000001 \ No newline at end of file diff --git a/cmd/thetacli/cmd/tx/main.go b/cmd/thetacli/cmd/tx/main.go index 372c6df2..d293d316 100644 --- a/cmd/thetacli/cmd/tx/main.go +++ b/cmd/thetacli/cmd/tx/main.go @@ -34,6 +34,8 @@ var ( sourceFlag string holderFlag string asyncFlag bool + onChainFlag bool + sourceSignatureFlag string ) // TxCmd represents the Tx command diff --git a/cmd/thetacli/cmd/tx/reserve_fund.go b/cmd/thetacli/cmd/tx/reserve_fund.go index 44106c16..e0095aa7 100644 --- a/cmd/thetacli/cmd/tx/reserve_fund.go +++ b/cmd/thetacli/cmd/tx/reserve_fund.go @@ -2,6 +2,7 @@ package tx import ( "encoding/hex" + "encoding/json" "fmt" "math/big" @@ -11,6 +12,7 @@ import ( "github.com/thetatoken/theta/ledger/types" "github.com/thetatoken/theta/rpc" + "github.com/ybbus/jsonrpc" rpcc "github.com/ybbus/jsonrpc" ) @@ -88,14 +90,33 @@ func doReserveFundCmd(cmd *cobra.Command, args []string) { client := rpcc.NewRPCClient(viper.GetString(utils.CfgRemoteRPCEndpoint)) - res, err := client.Call("theta.BroadcastRawTransaction", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) + //res, err := client.Call("theta.BroadcastRawTransaction", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) + var res *jsonrpc.RPCResponse + if asyncFlag { + res, err = client.Call("theta.BroadcastRawTransactionAsync", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) + } else { + res, err = client.Call("theta.BroadcastRawTransaction", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) + } + + if err != nil { utils.Error("Failed to broadcast transaction: %v\n", err) } if res.Error != nil { utils.Error("Server returned error: %v\n", res.Error) } - fmt.Printf("Successfully broadcasted transaction.\n") + result := &rpc.BroadcastRawTransactionResult{} + err = res.GetObject(result) + if err != nil { + utils.Error("Failed to parse server response: %v\n", err) + } + formatted, err := json.MarshalIndent(result, "", " ") + if err != nil { + utils.Error("Failed to parse server response: %v\n", err) + } + fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) + + //fmt.Printf("Successfully broadcasted transaction.\n") } func init() { @@ -108,6 +129,7 @@ func init() { reserveFundCmd.Flags().Uint64Var(&durationFlag, "duration", 1000, "Reserve duration") reserveFundCmd.Flags().StringSliceVar(&resourceIDsFlag, "resource_ids", []string{}, "Resource IDs") reserveFundCmd.Flags().StringVar(&walletFlag, "wallet", "soft", "Wallet type (soft|nano)") + reserveFundCmd.Flags().BoolVar(&asyncFlag, "async", false, "block until tx has been included in the blockchain") reserveFundCmd.MarkFlagRequired("chain") reserveFundCmd.MarkFlagRequired("from") diff --git a/cmd/thetacli/cmd/tx/service_payment.go b/cmd/thetacli/cmd/tx/service_payment.go index 12813acd..a2dd1473 100644 --- a/cmd/thetacli/cmd/tx/service_payment.go +++ b/cmd/thetacli/cmd/tx/service_payment.go @@ -9,7 +9,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" "github.com/thetatoken/theta/cmd/thetacli/cmd/utils" - "github.com/thetatoken/theta/common" +// "github.com/thetatoken/theta/common" + "github.com/thetatoken/theta/crypto" "github.com/thetatoken/theta/ledger/types" "github.com/thetatoken/theta/rpc" wtypes "github.com/thetatoken/theta/wallet/types" @@ -39,16 +40,31 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { utils.Error("The to address cannot be empty") return } + if fromFlag == toFlag { utils.Error("The from and to address cannot be identical") return } - wallet, fromAddress, err := walletUnlockWithPath(cmd, fromFlag, pathFlag) - if err != nil || wallet == nil { - return - } - defer wallet.Lock(fromAddress) +// var swallet wtypes.Wallet + //common.HexToAddress(addressStr) +// var fromAddress = common.BytesToAddress([]byte(fromFlag)) +// var twallet wtypes.Wallet +// var toAddress = common.BytesToAddress([]byte(toFlag)) + +// if onChainFlag { + twallet, toAddress, err := walletUnlockWithPath(cmd, toFlag, pathFlag) + if err != nil || twallet == nil { + return + } + defer twallet.Lock(toAddress) +// } else { + swallet, fromAddress, err := walletUnlockWithPath(cmd, fromFlag, pathFlag) + if err != nil || swallet == nil { + return + } + defer swallet.Lock(fromAddress) +// } fee, ok := types.ParseCoinAmount(feeFlag) if !ok { @@ -59,13 +75,13 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { Address: fromAddress, Coins: types.Coins{ ThetaWei: new(big.Int).SetUint64(0), - TFuelWei: new(big.Int).SetUint64(0), + TFuelWei: new(big.Int).SetUint64(1), }, Sequence: uint64(paymentSeqFlag), } tinput := types.TxInput{ - Address: common.HexToAddress(toFlag), + Address: toAddress, Coins: types.Coins{ ThetaWei: new(big.Int).SetUint64(0), TFuelWei: new(big.Int).SetUint64(0), @@ -86,17 +102,33 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { ResourceID: resourceIDFlag, } - ssig, err := wallet.Sign(fromAddress, servicePaymentTx.SourceSignBytes(chainIDFlag)) - if err != nil { - utils.Error("Failed to sign source transaction: %v\n", err) - } - servicePaymentTx.SetSourceSignature(ssig) - - tsig, err := wallet.Sign(tinput.Address, servicePaymentTx.TargetSignBytes(chainIDFlag)) - if err != nil { - utils.Error("Failed to sign target transaction: %v\n", err) + if onChainFlag { + ssig, err := crypto.SignatureFromBytes([]byte(sourceSignatureFlag)) + if err != nil { + utils.Error("Failed to convert passed signature: %v\n", err) + } + servicePaymentTx.SetSourceSignature(ssig) + } else { + ssig, err := swallet.Sign(fromAddress, servicePaymentTx.SourceSignBytes(chainIDFlag)) + if err != nil { + utils.Error("Failed to sign source transaction: %v\n", err) + } + servicePaymentTx.SetSourceSignature(ssig) + } + + if onChainFlag { + tsig, err := twallet.Sign(toAddress, servicePaymentTx.TargetSignBytes(chainIDFlag)) + if err != nil { + utils.Error("Failed to sign target transaction: %v\n", err) + } + servicePaymentTx.SetTargetSignature(tsig) + } else { + tsig, err := crypto.SignatureFromBytes([]byte("unsigned")) + if err != nil { + utils.Error("Failed to convert passed signature: %v\n", err) + } + servicePaymentTx.SetTargetSignature(tsig) } - servicePaymentTx.SetTargetSignature(tsig) raw, err := types.TxToBytes(servicePaymentTx) if err != nil { @@ -104,31 +136,40 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { } signedTx := hex.EncodeToString(raw) - client := rpcc.NewRPCClient(viper.GetString(utils.CfgRemoteRPCEndpoint)) - - var res *jsonrpc.RPCResponse - if asyncFlag { - res, err = client.Call("theta.BroadcastRawTransactionAsync", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) + if onChainFlag { + client := rpcc.NewRPCClient(viper.GetString(utils.CfgRemoteRPCEndpoint)) + + var res *jsonrpc.RPCResponse + if asyncFlag { + res, err = client.Call("theta.BroadcastRawTransactionAsync", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) + } else { + res, err = client.Call("theta.BroadcastRawTransaction", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) + } + + if err != nil { + utils.Error("Failed to broadcast transaction: %v\n", err) + } + if res.Error != nil { + utils.Error("Server returned error: %v\n", res.Error) + } + result := &rpc.BroadcastRawTransactionResult{} + err = res.GetObject(result) + if err != nil { + utils.Error("Failed to parse server response: %v\n", err) + } + formatted, err := json.MarshalIndent(result, "", " ") + if err != nil { + utils.Error("Failed to parse server response: %v\n", err) + } + fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) } else { - res, err = client.Call("theta.BroadcastRawTransaction", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) + formatted, err := json.MarshalIndent(servicePaymentTx, "", " ") + if err != nil { + utils.Error("Failed to parse off-chain transaction: %v\n", err) + } + fmt.Printf("Off-Chain transaction:\n%s\n", formatted) } - if err != nil { - utils.Error("Failed to broadcast transaction: %v\n", err) - } - if res.Error != nil { - utils.Error("Server returned error: %v\n", res.Error) - } - result := &rpc.BroadcastRawTransactionResult{} - err = res.GetObject(result) - if err != nil { - utils.Error("Failed to parse server response: %v\n", err) - } - formatted, err := json.MarshalIndent(result, "", " ") - if err != nil { - utils.Error("Failed to parse server response: %v\n", err) - } - fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) } func init() { @@ -141,7 +182,9 @@ func init() { servicePaymentCmd.Flags().StringVar(&resourceIDFlag, "resource_id", "", "Corresponding resourceID") servicePaymentCmd.Flags().StringVar(&feeFlag, "fee", fmt.Sprintf("%dwei", types.MinimumTransactionFeeTFuelWei), "Fee") servicePaymentCmd.Flags().StringVar(&walletFlag, "wallet", "soft", "Wallet type (soft|nano|trezor)") - servicePaymentCmd.Flags().BoolVar(&asyncFlag, "async", false, "block until tx has been included in the blockchain") + servicePaymentCmd.Flags().StringVar(&sourceSignatureFlag, "src_sig", "unsigned", "Source Signature from prior Off-Chain transaction") + servicePaymentCmd.Flags().BoolVar(&onChainFlag, "on_chain", false, "Process transaction On-Chain else return json of what would have been sent") + servicePaymentCmd.Flags().BoolVar(&asyncFlag, "async", false, "Block until tx has been included in the blockchain") servicePaymentCmd.MarkFlagRequired("chain") servicePaymentCmd.MarkFlagRequired("from") From 587b902443d4dde7258f728073d8692de269861f Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Fri, 4 Jun 2021 18:01:13 -0400 Subject: [PATCH 03/20] off-chain kinda working --- NOTES.md | 63 +++++++++++++++-- cmd/thetacli/cmd/tx/main.go | 1 + cmd/thetacli/cmd/tx/service_payment.go | 97 ++++++++++++++++---------- 3 files changed, 120 insertions(+), 41 deletions(-) diff --git a/NOTES.md b/NOTES.md index 0726d89b..fe164955 100644 --- a/NOTES.md +++ b/NOTES.md @@ -128,13 +128,66 @@ func TestServicePaymentTxNormalExecutionAndSlash(t *testing.T) { //assert.Equal(1, len(et.state().Delivered().GetSlashIntents())) +// Set up for Off-Chain testing -thetacli tx reserve --async --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --fund=10 --collateral=11 --duration=1001 --resource_ids=rid1000001 --seq=1 +thetacli query account --address=2E833968E5bB786Ae419c4d13189fB081Cc43bab -"hash": "0x711e0001d454a556f6f1408f23f263fd2023c4c0e8eb54f5add1aaac137c8370", -thetacli query tx --hash=711e0001d454a556f6f1408f23f263fd2023c4c0e8eb54f5add1aaac137c8370 +thetacli tx reserve --async --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --fund=10 --collateral=11 --duration=31 --resource_ids=rid1000001 --seq=1 -thetacli tx service_payment --on_chain --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=2 --resource_id=rid1000001 +thetacli tx send --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --theta=0 --tfuel=1 --seq=2 -thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=2 --resource_id=rid1000001 \ No newline at end of file +thetacli query account --address=2E833968E5bB786Ae419c4d13189fB081Cc43bab + +thetacli query account --address=70f587259738cB626A1720Af7038B8DcDb6a42a0 + +// Alice : I want rid1000001 and I'm willing to pay up to 10 TFuel for it. +thetacli query account --address=2E833968E5bB786Ae419c4d13189fB081Cc43bab + +thetacli tx reserve --async --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --fund=10 --collateral=11 --duration=101 --resource_ids=rid1000001 --seq=12 + +thetacli query account --address=2E833968E5bB786Ae419c4d13189fB081Cc43bab + +"hash": "0x4bb258b6784ec0a755e5ab7dfb50403a462866ebac3d27c96463b2a1becd65ca" + +thetacli query tx --hash=0x3d38c3851ae49072400b9f4c63fea1511b600552ff0eed4f008eb1d5cec5013a + +// Alice -> Bob +"end_block_height": "1533" +thetacli query tx --hash=0x29745a458dc5e1f39a511b889f04396d1add0a16ad279816b46dfa496b1fa228 +// Alice <- Bob +--resource_id=rid1000001 + +// Alice -> Bob +thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=12 --resource_id=rid1000001 --tfuel=2 + +--resource_id=rid1000001 + +thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=2 --reserve_seq=12 --resource_id=rid1000001 --tfuel=2 + +// Alice -> Carol +thetacli query tx --hash=0x29745a458dc5e1f39a511b889f04396d1add0a16ad279816b46dfa496b1fa228 +// Alice <- Carol +--resource_id=rid1000001 + +// Alice -> Carol +thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 --payment_seq=3 --reserve_seq=12 --resource_id=rid1000001 --tfuel=2 + +--resource_id=rid1000001 + +thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 --payment_seq=4 --reserve_seq=13 --resource_id=rid1000001 --tfuel=4 + + +// Bob -> Payout +thetacli query tx --hash=0x3d38c3851ae49072400b9f4c63fea1511b600552ff0eed4f008eb1d5cec5013a + +thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=12 --resource_id=rid1000001 --tfuel=2 --on_chain --src_sig=0x12bd5090066cb508b50c437faba261afca2ed1c985812a2f7e4d2a6321d9128c33a5456c4105ceafb3da7897cfb97b50e6ff70e1ba7aaf0ba562890246ec728801 + +thetacli query account --address=70f587259738cB626A1720Af7038B8DcDb6a42a0 + +// Carol -> Payout +thetacli query tx --hash=0x3d38c3851ae49072400b9f4c63fea1511b600552ff0eed4f008eb1d5cec5013a + +thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 --payment_seq=4 --reserve_seq=12 --resource_id=rid1000001 --tfuel=4 --on_chain --src_sig=0x1114ce5922a7e940542468fc2b6cd22f779408224310d63eb6215171e8618daf53432533b207704dcd2d21235a8e40e84819df369154b01f7a47357e496250e801 + +thetacli query account --address=0xcd56123D0c5D6C1Ba4D39367b88cba61D93F5405 diff --git a/cmd/thetacli/cmd/tx/main.go b/cmd/thetacli/cmd/tx/main.go index d293d316..71e3af9d 100644 --- a/cmd/thetacli/cmd/tx/main.go +++ b/cmd/thetacli/cmd/tx/main.go @@ -36,6 +36,7 @@ var ( asyncFlag bool onChainFlag bool sourceSignatureFlag string + dryRunFlag bool ) // TxCmd represents the Tx command diff --git a/cmd/thetacli/cmd/tx/service_payment.go b/cmd/thetacli/cmd/tx/service_payment.go index a2dd1473..ab4913bf 100644 --- a/cmd/thetacli/cmd/tx/service_payment.go +++ b/cmd/thetacli/cmd/tx/service_payment.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" "github.com/thetatoken/theta/cmd/thetacli/cmd/utils" -// "github.com/thetatoken/theta/common" + "github.com/thetatoken/theta/common" "github.com/thetatoken/theta/crypto" "github.com/thetatoken/theta/ledger/types" "github.com/thetatoken/theta/rpc" @@ -46,25 +46,32 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { return } -// var swallet wtypes.Wallet + var swallet wtypes.Wallet //common.HexToAddress(addressStr) -// var fromAddress = common.BytesToAddress([]byte(fromFlag)) -// var twallet wtypes.Wallet -// var toAddress = common.BytesToAddress([]byte(toFlag)) + var fromAddress = common.HexToAddress(fromFlag) + var twallet wtypes.Wallet + var toAddress = common.HexToAddress(toFlag) + var err error -// if onChainFlag { - twallet, toAddress, err := walletUnlockWithPath(cmd, toFlag, pathFlag) + if onChainFlag { +// if 1 == 1 { + twallet, toAddress, err = walletUnlockWithPath(cmd, toFlag, pathFlag) if err != nil || twallet == nil { return } defer twallet.Lock(toAddress) -// } else { - swallet, fromAddress, err := walletUnlockWithPath(cmd, fromFlag, pathFlag) + } else { + swallet, fromAddress, err = walletUnlockWithPath(cmd, fromFlag, pathFlag) if err != nil || swallet == nil { return } defer swallet.Lock(fromAddress) -// } + } + + tfuel, ok := types.ParseCoinAmount(tfuelAmountFlag) + if !ok { + utils.Error("Failed to parse tfuel amount") + } fee, ok := types.ParseCoinAmount(feeFlag) if !ok { @@ -75,18 +82,23 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { Address: fromAddress, Coins: types.Coins{ ThetaWei: new(big.Int).SetUint64(0), - TFuelWei: new(big.Int).SetUint64(1), + //TFuelWei: new(big.Int).Add(tfuel, fee), + TFuelWei: tfuel, + //TFuelWei: new(big.Int).SetUint64(1), }, Sequence: uint64(paymentSeqFlag), + //Signature: } tinput := types.TxInput{ Address: toAddress, Coins: types.Coins{ ThetaWei: new(big.Int).SetUint64(0), - TFuelWei: new(big.Int).SetUint64(0), + TFuelWei: tfuel, + //TFuelWei: new(big.Int).SetUint64(0), }, //Sequence: uint64(paymentSeqFlag), + //Signature: } // See theta-protocol-ledger > ledger > types > tx.go : Line 522 @@ -103,7 +115,8 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { } if onChainFlag { - ssig, err := crypto.SignatureFromBytes([]byte(sourceSignatureFlag)) + //ssig, err := crypto.UnmarshalJSON([]byte(sourceSignatureFlag)) + ssig, err := crypto.SignatureFromBytes(common.FromHex(sourceSignatureFlag)) if err != nil { utils.Error("Failed to convert passed signature: %v\n", err) } @@ -137,31 +150,41 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { signedTx := hex.EncodeToString(raw) if onChainFlag { - client := rpcc.NewRPCClient(viper.GetString(utils.CfgRemoteRPCEndpoint)) - - var res *jsonrpc.RPCResponse - if asyncFlag { - res, err = client.Call("theta.BroadcastRawTransactionAsync", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) + if dryRunFlag { + formatted, err := json.MarshalIndent(servicePaymentTx, "", " ") + if err != nil { + utils.Error("Failed to parse off-chain transaction: %v\n", err) + } + fmt.Printf("On-Chain transaction(dry-run):\n%s\n", formatted) + } else { - res, err = client.Call("theta.BroadcastRawTransaction", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) - } - if err != nil { - utils.Error("Failed to broadcast transaction: %v\n", err) - } - if res.Error != nil { - utils.Error("Server returned error: %v\n", res.Error) - } - result := &rpc.BroadcastRawTransactionResult{} - err = res.GetObject(result) - if err != nil { - utils.Error("Failed to parse server response: %v\n", err) + client := rpcc.NewRPCClient(viper.GetString(utils.CfgRemoteRPCEndpoint)) + + var res *jsonrpc.RPCResponse + if asyncFlag { + res, err = client.Call("theta.BroadcastRawTransactionAsync", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) + } else { + res, err = client.Call("theta.BroadcastRawTransaction", rpc.BroadcastRawTransactionArgs{TxBytes: signedTx}) + } + + if err != nil { + utils.Error("Failed to broadcast transaction: %v\n", err) + } + if res.Error != nil { + utils.Error("Server returned error: %v\n", res.Error) + } + result := &rpc.BroadcastRawTransactionResult{} + err = res.GetObject(result) + if err != nil { + utils.Error("Failed to parse server response: %v\n", err) + } + formatted, err := json.MarshalIndent(result, "", " ") + if err != nil { + utils.Error("Failed to parse server response: %v\n", err) + } + fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) } - formatted, err := json.MarshalIndent(result, "", " ") - if err != nil { - utils.Error("Failed to parse server response: %v\n", err) - } - fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) } else { formatted, err := json.MarshalIndent(servicePaymentTx, "", " ") if err != nil { @@ -179,13 +202,15 @@ func init() { servicePaymentCmd.Flags().StringVar(&pathFlag, "path", "", "Wallet derivation path") servicePaymentCmd.Flags().Uint64Var(&paymentSeqFlag, "payment_seq", 0, "Payment sequence number of the transaction") servicePaymentCmd.Flags().Uint64Var(&reserveSeqFlag, "reserve_seq", 0, "Reserve sequence number of the transaction") + servicePaymentCmd.Flags().StringVar(&tfuelAmountFlag, "tfuel", "0", "TFuel amount") servicePaymentCmd.Flags().StringVar(&resourceIDFlag, "resource_id", "", "Corresponding resourceID") servicePaymentCmd.Flags().StringVar(&feeFlag, "fee", fmt.Sprintf("%dwei", types.MinimumTransactionFeeTFuelWei), "Fee") servicePaymentCmd.Flags().StringVar(&walletFlag, "wallet", "soft", "Wallet type (soft|nano|trezor)") servicePaymentCmd.Flags().StringVar(&sourceSignatureFlag, "src_sig", "unsigned", "Source Signature from prior Off-Chain transaction") servicePaymentCmd.Flags().BoolVar(&onChainFlag, "on_chain", false, "Process transaction On-Chain else return json of what would have been sent") servicePaymentCmd.Flags().BoolVar(&asyncFlag, "async", false, "Block until tx has been included in the blockchain") - + servicePaymentCmd.Flags().BoolVar(&dryRunFlag, "dry_run", false, "Dry Run(don't execute) the On-Chain transaction") + servicePaymentCmd.MarkFlagRequired("chain") servicePaymentCmd.MarkFlagRequired("from") servicePaymentCmd.MarkFlagRequired("to") From 6bef452b557104ababf129fc72d48dcbf090887f Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Mon, 7 Jun 2021 19:07:47 -0400 Subject: [PATCH 04/20] test batch.sh --- cmd/thetacli/test/batch.sh | 110 +++++++++++++++++++++++++++++++++++ cmd/thetacli/test/defaultpw | 2 + cmd/thetacli/test/reserve.sh | 15 +++++ cmd/thetacli/test/send.sh | 15 +++++ cmd/thetacli/test/sp.out | 34 +++++++++++ cmd/thetacli/test/sp.sh | 17 ++++++ 6 files changed, 193 insertions(+) create mode 100755 cmd/thetacli/test/batch.sh create mode 100644 cmd/thetacli/test/defaultpw create mode 100755 cmd/thetacli/test/reserve.sh create mode 100755 cmd/thetacli/test/send.sh create mode 100644 cmd/thetacli/test/sp.out create mode 100755 cmd/thetacli/test/sp.sh diff --git a/cmd/thetacli/test/batch.sh b/cmd/thetacli/test/batch.sh new file mode 100755 index 00000000..b628e103 --- /dev/null +++ b/cmd/thetacli/test/batch.sh @@ -0,0 +1,110 @@ +#!/bin/bash +#set -x #echo on + +Alice=2E833968E5bB786Ae419c4d13189fB081Cc43bab +Bob=70f587259738cB626A1720Af7038B8DcDb6a42a0 +Carol=cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 +rid=rid1000001 +rpduration=51 + +##################################################################### +# Default scale used by float functions. + +float_scale=18 +z18=1000000000000000000 + +##################################################################### +# Evaluate a floating point number expression. + +function un_wei() +{ + local stat=0 + local result=0.0 + if [[ $# -gt 0 ]]; then + result=$(echo "scale=$float_scale; $*/$z18" | bc -q 2>/dev/null) + stat=$? + if [[ $stat -eq 0 && -z "$result" ]]; then stat=1; fi + fi + echo $result + return $stat +} + + +cbh=$(thetacli query status | tail -n +2 | jq .current_height) + +aib=$(thetacli query account --address=$Alice | tail -n +2 | jq .coins.tfuelwei | tr -d '"') +aseq=$(thetacli query account --address=$Alice | tail -n +2 | jq .sequence | tr -d '"') +ans=$(( $aseq + 1 )) +echo "Alice initial balance: "$(un_wei $aib) +echo "Alice next sequence: "$ans +arf=$(thetacli query account --address=$Alice | tail -n +2 | jq .reserved_funds) + +#echo "arf:"${#arf} + +if [ ${#arf} == 2 ]; then + echo "No Reserve Fund" + echo "Alice begin create reserve." + ./reserve.sh --from=$Alice --fund=10 --collateral=11 --duration=$rpduration --resource_ids=$rid --seq=$ans + echo "Alice end create reserve." + + exit +else + echo "Reserve Fund Exists" + #echo "arf:"$arf + ebh=$(echo "$arf" | jq .[0].end_block_height) + echo "end_block_height:"$ebh + echo "current_block_height:"$(thetacli query status | tail -n +2 | jq .current_height) +fi + + +#printf "Alice :%d\n" $aib + +#./send.sh --from=$Alice --to=$Bob --theta=0 --tfuel=1 --seq=$ans + +aab=$(thetacli query account --address=$Alice | tail -n +2 | jq .coins.tfuelwei | tr -d '"') +bab=$(thetacli query account --address=$Bob | tail -n +2 | jq .coins.tfuelwei | tr -d '"') + +echo "Alice after balance: "$(un_wei $aab) +echo "Bob after balance: "$(un_wei $bab) + +aseq=$(thetacli query account --address=$Alice | tail -n +2 | jq .sequence | tr -d '"') +ans=$(( $aseq + 1 )) + +declare -a sigs + +i=0 +bobcnt=1 +while [ $i -lt $bobcnt ]; do + sigout=$(./sp.sh --from=$Alice --to=$Bob --payment_seq=$i --reserve_seq=$ans --resource_id=$rid --tfuel=2 | tail -n +8 | jq .source.signature | tr -d '"') + sigs+=($sigout) + let i++ +done + +carolcnt=$(( $bobcnt+1 )) +while [ $i -lt $carolcnt ]; do + sigout=$(./sp.sh --from=$Alice --to=$Carol --payment_seq=$i --reserve_seq=$ans --resource_id=$rid --tfuel=2 | tail -n +8 | jq .source.signature | tr -d '"') + sigs+=($sigout) + let i++ +done + +for sig in "${sigs[@]}" +do + echo "SIG:"$sig +done + +i=0 +bobcnt=1 +while [ $i -lt $bobcnt ]; do + sig=${sigs[$i]} + echo "Bob"$i":"$sig + ./sp.sh --from=$Alice --to=$Bob --payment_seq=$i --reserve_seq=$ans --resource_id=$rid --tfuel=2 --on_chain --src_sig=$sig + let i++ +done +while [ $i -lt $carolcnt ]; do + #sigout=$(./sp.sh --from=$Alice --to=$Bob --payment_seq=$i --reserve_seq=$ans --resource_id=$rid --tfuel=2 | tail -n +8 | jq .source.signature) + #sigs+=($sigout) + echo "Carol"$i":"${sigs[$i]} + let i++ +done + + diff --git a/cmd/thetacli/test/defaultpw b/cmd/thetacli/test/defaultpw new file mode 100644 index 00000000..bea1f091 --- /dev/null +++ b/cmd/thetacli/test/defaultpw @@ -0,0 +1,2 @@ +qwertyuiop + diff --git a/cmd/thetacli/test/reserve.sh b/cmd/thetacli/test/reserve.sh new file mode 100755 index 00000000..d4b8dfd9 --- /dev/null +++ b/cmd/thetacli/test/reserve.sh @@ -0,0 +1,15 @@ +#!/usr/bin/expect -f +set timeout -1 +set arg1 [lindex $argv 0] +set arg2 [lindex $argv 1] +set arg3 [lindex $argv 2] +set arg4 [lindex $argv 3] +set arg5 [lindex $argv 4] +set arg6 [lindex $argv 5] +spawn thetacli tx reserve --async --chain="privatenet" $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 +set code [open "./defaultpw" r] +set pass [read $code] +expect { + password: {send "$pass\r" ; exp_continue} + eof exit +} diff --git a/cmd/thetacli/test/send.sh b/cmd/thetacli/test/send.sh new file mode 100755 index 00000000..c28d3be1 --- /dev/null +++ b/cmd/thetacli/test/send.sh @@ -0,0 +1,15 @@ +#!/usr/bin/expect -f +set timeout -1 +set arg1 [lindex $argv 0] +set arg2 [lindex $argv 1] +set arg3 [lindex $argv 2] +set arg4 [lindex $argv 3] +set arg5 [lindex $argv 4] +set arg6 [lindex $argv 5] +spawn thetacli tx send --chain="privatenet" $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 +set code [open "./defaultpw" r] +set pass [read $code] +expect { + password: {send "$pass\r" ; exp_continue} + eof exit +} diff --git a/cmd/thetacli/test/sp.out b/cmd/thetacli/test/sp.out new file mode 100644 index 00000000..635df76e --- /dev/null +++ b/cmd/thetacli/test/sp.out @@ -0,0 +1,34 @@ +spawn thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=3 --resource_id=rid1000001 --tfuel=2 +Using config file: /Users/i830671/.thetacli/config.yaml +Please enter password: qwertyuiop + + + +Off-Chain transaction: +{ + "fee": { + "thetawei": "0", + "tfuelwei": "1000000000000" + }, + "source": { + "address": "0x2e833968e5bb786ae419c4d13189fb081cc43bab", + "coins": { + "thetawei": "0", + "tfuelwei": "2000000000000000000" + }, + "sequence": "1", + "signature": "0x5dc0a9661ad351c3d62e42359e9d514345b40fe93679578efb0140ebd1130d904598892ac5c444e96287855ec2a684cf9ba162b2ffe72feca8540a92f83a9ad500" + }, + "target": { + "address": "0x70f587259738cb626a1720af7038b8dcdb6a42a0", + "coins": { + "thetawei": "0", + "tfuelwei": "2000000000000000000" + }, + "sequence": "0", + "signature": "0x756e7369676e6564" + }, + "payment_sequence": "1", + "reserve_sequence": "3", + "resource_id": "rid1000001" +} diff --git a/cmd/thetacli/test/sp.sh b/cmd/thetacli/test/sp.sh new file mode 100755 index 00000000..b3de35e2 --- /dev/null +++ b/cmd/thetacli/test/sp.sh @@ -0,0 +1,17 @@ +#!/usr/bin/expect -f +set timeout -1 +set arg1 [lindex $argv 0] +set arg2 [lindex $argv 1] +set arg3 [lindex $argv 2] +set arg4 [lindex $argv 3] +set arg5 [lindex $argv 4] +set arg6 [lindex $argv 5] +set arg7 [lindex $argv 6] +set arg8 [lindex $argv 7] +spawn thetacli tx service_payment --chain="privatenet" $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 $arg7 $arg8 +set code [open "./defaultpw" r] +set pass [read $code] +expect { + password: {send "$pass\r" ; exp_continue} + eof exit +} From 8a9584b9a7bce1698b49aed0aa9b8398d5f12ce4 Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Tue, 8 Jun 2021 18:14:04 -0400 Subject: [PATCH 05/20] better batch --- NOTES.md | 19 ++- cmd/thetacli/cmd/root.go | 3 +- cmd/thetacli/cmd/tx/deposit_stake.go | 1 + cmd/thetacli/cmd/tx/main.go | 3 +- cmd/thetacli/cmd/tx/release_fund.go | 1 + cmd/thetacli/cmd/tx/reserve_fund.go | 1 + cmd/thetacli/cmd/tx/send.go | 1 + cmd/thetacli/cmd/tx/service_payment.go | 7 +- cmd/thetacli/cmd/tx/smart_contract.go | 1 + cmd/thetacli/cmd/tx/split_rule.go | 1 + cmd/thetacli/cmd/tx/utils.go | 35 ++++- cmd/thetacli/cmd/tx/withdraw_stake.go | 1 + cmd/thetacli/test/batch.sh | 187 ++++++++++++++++++++----- cmd/thetacli/test/defaultpw | 3 +- cmd/thetacli/test/reserve.sh | 2 +- cmd/thetacli/test/sp.out | 34 ----- 16 files changed, 224 insertions(+), 76 deletions(-) delete mode 100644 cmd/thetacli/test/sp.out diff --git a/NOTES.md b/NOTES.md index fe164955..76142bdc 100644 --- a/NOTES.md +++ b/NOTES.md @@ -159,7 +159,7 @@ thetacli query tx --hash=0x29745a458dc5e1f39a511b889f04396d1add0a16ad279816b46df --resource_id=rid1000001 // Alice -> Bob -thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=12 --resource_id=rid1000001 --tfuel=2 +thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=8 --resource_id=rid1000001 --tfuel=2 --resource_id=rid1000001 @@ -181,7 +181,7 @@ thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d1 // Bob -> Payout thetacli query tx --hash=0x3d38c3851ae49072400b9f4c63fea1511b600552ff0eed4f008eb1d5cec5013a -thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=12 --resource_id=rid1000001 --tfuel=2 --on_chain --src_sig=0x12bd5090066cb508b50c437faba261afca2ed1c985812a2f7e4d2a6321d9128c33a5456c4105ceafb3da7897cfb97b50e6ff70e1ba7aaf0ba562890246ec728801 +thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=8 --resource_id=rid1000001 --tfuel=2 --on_chain --src_sig=0x9bc43df9cfb50a0284161543709a3cad4d55a42ad74e2e8520af74730a9977b835aa976803a473451ca109c4032b8c947d7edb8499c949a6926231db8b4f53c900 thetacli query account --address=70f587259738cB626A1720Af7038B8DcDb6a42a0 @@ -191,3 +191,18 @@ thetacli query tx --hash=0x3d38c3851ae49072400b9f4c63fea1511b600552ff0eed4f008eb thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 --payment_seq=4 --reserve_seq=12 --resource_id=rid1000001 --tfuel=4 --on_chain --src_sig=0x1114ce5922a7e940542468fc2b6cd22f779408224310d63eb6215171e8618daf53432533b207704dcd2d21235a8e40e84819df369154b01f7a47357e496250e801 thetacli query account --address=0xcd56123D0c5D6C1Ba4D39367b88cba61D93F5405 + + + + +thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=2 --reserve_seq=8 --resource_id=rid1000001 --tfuel=2 + +thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=2 --reserve_seq=8 --resource_id=rid1000001 --tfuel=2 --on_chain --src_sig=0x9e2ff11e85636b8aece02127db7b9bfa4ffdff144a026f99aeb6f375d0c21ec244618896410d3bad9eaad560162ffb8c00b6906ef9a424a2354173342119a00201 + +0x12bd5090066cb508b50c437faba261afca2ed1c985812a2f7e4d2a6321d9128c33a5456c4105ceafb3da7897cfb97b50e6ff70e1ba7aaf0ba562890246ec728801 + +thetacli tx release --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --reserve_seq=17 --seq=18 +Using config file: /Users/i830671/.thetacli/config.yaml +Please enter password: +Server returned error: -32000: Fund cannot be released until blockheight 3051 + diff --git a/cmd/thetacli/cmd/root.go b/cmd/thetacli/cmd/root.go index 4b1df1aa..f07bb989 100644 --- a/cmd/thetacli/cmd/root.go +++ b/cmd/thetacli/cmd/root.go @@ -62,7 +62,8 @@ func initConfig() { // If a config file is found, read it in. if err := viper.ReadInConfig(); err == nil { - fmt.Println("Using config file:", viper.ConfigFileUsed()) + // Noisey output causes output parsing difficulty + //fmt.Println("Using config file:", viper.ConfigFileUsed()) } } diff --git a/cmd/thetacli/cmd/tx/deposit_stake.go b/cmd/thetacli/cmd/tx/deposit_stake.go index 6225e34c..5b352ab5 100644 --- a/cmd/thetacli/cmd/tx/deposit_stake.go +++ b/cmd/thetacli/cmd/tx/deposit_stake.go @@ -134,6 +134,7 @@ func doDepositStakeCmd(cmd *cobra.Command, args []string) { } func init() { + depositStakeCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") depositStakeCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") depositStakeCmd.Flags().StringVar(&sourceFlag, "source", "", "Source of the stake") depositStakeCmd.Flags().StringVar(&holderFlag, "holder", "", "Holder of the stake") diff --git a/cmd/thetacli/cmd/tx/main.go b/cmd/thetacli/cmd/tx/main.go index 71e3af9d..95c56462 100644 --- a/cmd/thetacli/cmd/tx/main.go +++ b/cmd/thetacli/cmd/tx/main.go @@ -37,6 +37,7 @@ var ( onChainFlag bool sourceSignatureFlag string dryRunFlag bool + pwFlag string ) // TxCmd represents the Tx command @@ -50,7 +51,7 @@ func init() { TxCmd.AddCommand(sendCmd) TxCmd.AddCommand(reserveFundCmd) TxCmd.AddCommand(servicePaymentCmd) - //TxCmd.AddCommand(releaseFundCmd) // No need for releaseFundCmd since auto-release is already implemented + TxCmd.AddCommand(releaseFundCmd) // No need for releaseFundCmd since auto-release is already implemented TxCmd.AddCommand(splitRuleCmd) TxCmd.AddCommand(smartContractCmd) TxCmd.AddCommand(depositStakeCmd) diff --git a/cmd/thetacli/cmd/tx/release_fund.go b/cmd/thetacli/cmd/tx/release_fund.go index 38f26486..98464af7 100644 --- a/cmd/thetacli/cmd/tx/release_fund.go +++ b/cmd/thetacli/cmd/tx/release_fund.go @@ -74,6 +74,7 @@ func doReleaseFundCmd(cmd *cobra.Command, args []string) { } func init() { + releaseFundCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") releaseFundCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") releaseFundCmd.Flags().StringVar(&fromFlag, "from", "", "Reserve owner's address") releaseFundCmd.Flags().Uint64Var(&seqFlag, "seq", 0, "Sequence number of the transaction") diff --git a/cmd/thetacli/cmd/tx/reserve_fund.go b/cmd/thetacli/cmd/tx/reserve_fund.go index 5918373b..1b1aaf25 100644 --- a/cmd/thetacli/cmd/tx/reserve_fund.go +++ b/cmd/thetacli/cmd/tx/reserve_fund.go @@ -120,6 +120,7 @@ func doReserveFundCmd(cmd *cobra.Command, args []string) { } func init() { + reserveFundCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") reserveFundCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") reserveFundCmd.Flags().StringVar(&fromFlag, "from", "", "Address to send from") reserveFundCmd.Flags().Uint64Var(&seqFlag, "seq", 0, "Sequence number of the transaction") diff --git a/cmd/thetacli/cmd/tx/send.go b/cmd/thetacli/cmd/tx/send.go index 3c2e35b1..60a3d250 100644 --- a/cmd/thetacli/cmd/tx/send.go +++ b/cmd/thetacli/cmd/tx/send.go @@ -128,6 +128,7 @@ func doSendCmd(cmd *cobra.Command, args []string) { } func init() { + sendCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") sendCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") sendCmd.Flags().StringVar(&fromFlag, "from", "", "Address to send from") sendCmd.Flags().StringVar(&toFlag, "to", "", "Address to send to") diff --git a/cmd/thetacli/cmd/tx/service_payment.go b/cmd/thetacli/cmd/tx/service_payment.go index ab4913bf..fc486ca9 100644 --- a/cmd/thetacli/cmd/tx/service_payment.go +++ b/cmd/thetacli/cmd/tx/service_payment.go @@ -155,7 +155,8 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { if err != nil { utils.Error("Failed to parse off-chain transaction: %v\n", err) } - fmt.Printf("On-Chain transaction(dry-run):\n%s\n", formatted) + //fmt.Printf("On-Chain transaction(dry-run):\n%s\n", formatted) + fmt.Printf("%s\n", formatted) } else { @@ -190,12 +191,14 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { if err != nil { utils.Error("Failed to parse off-chain transaction: %v\n", err) } - fmt.Printf("Off-Chain transaction:\n%s\n", formatted) + //fmt.Printf("Off-Chain transaction:\n%s\n", formatted) + fmt.Printf("%s\n", formatted) } } func init() { + servicePaymentCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") servicePaymentCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") servicePaymentCmd.Flags().StringVar(&fromFlag, "from", "", "Address to send from") servicePaymentCmd.Flags().StringVar(&toFlag, "to", "", "Address to send to") diff --git a/cmd/thetacli/cmd/tx/smart_contract.go b/cmd/thetacli/cmd/tx/smart_contract.go index 4915b8cf..cf29bbe8 100644 --- a/cmd/thetacli/cmd/tx/smart_contract.go +++ b/cmd/thetacli/cmd/tx/smart_contract.go @@ -115,6 +115,7 @@ func doSmartContractCmd(cmd *cobra.Command, args []string) { } func init() { + smartContractCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") smartContractCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") smartContractCmd.Flags().StringVar(&fromFlag, "from", "", "The caller address") smartContractCmd.Flags().StringVar(&toFlag, "to", "", "The smart contract address") diff --git a/cmd/thetacli/cmd/tx/split_rule.go b/cmd/thetacli/cmd/tx/split_rule.go index 3bbfa8bd..cf1a189d 100644 --- a/cmd/thetacli/cmd/tx/split_rule.go +++ b/cmd/thetacli/cmd/tx/split_rule.go @@ -106,6 +106,7 @@ func doSplitRuleCmd(cmd *cobra.Command, args []string) { } func init() { + splitRuleCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") splitRuleCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") splitRuleCmd.Flags().StringVar(&fromFlag, "from", "", "Initiator's address") splitRuleCmd.Flags().Uint64Var(&seqFlag, "seq", 0, "Sequence number of the transaction") diff --git a/cmd/thetacli/cmd/tx/utils.go b/cmd/thetacli/cmd/tx/utils.go index b3f55027..ba4b185a 100644 --- a/cmd/thetacli/cmd/tx/utils.go +++ b/cmd/thetacli/cmd/tx/utils.go @@ -29,7 +29,14 @@ func walletUnlockWithPath(cmd *cobra.Command, addressStr string, path string) (w walletType := getWalletType(cmd) if walletType == wtypes.WalletTypeSoft { cfgPath := cmd.Flag("config").Value.String() - wallet, address, err = SoftWalletUnlock(cfgPath, addressStr) + var cfgPW string = "" + cfgPW = cmd.Flag("pw").Value.String() + if cfgPW == "" { + wallet, address, err = SoftWalletUnlock(cfgPath, addressStr) + } else { + wallet, address, err = SoftWalletUnlockPW(cfgPath, addressStr, cfgPW) + } + //wallet, address, err = SoftWalletUnlock(cfgPath, addressStr) } else { derivationPath, err := parseDerivationPath(path, walletType) if err != nil { @@ -95,6 +102,32 @@ func SoftWalletUnlock(cfgPath, addressStr string) (wtypes.Wallet, common.Address return wallet, address, nil } +func SoftWalletUnlockPW(cfgPath, addressStr string, password string) (wtypes.Wallet, common.Address, error) { + wallet, err := wallet.OpenWallet(cfgPath, wtypes.WalletTypeSoft, true) + if err != nil { + fmt.Printf("Failed to open wallet: %v\n", err) + return nil, common.Address{}, err + } + + //prompt := fmt.Sprintf("Please enter pasword: ") + //password, err := utils.GetPassword(prompt) + //if err != nil { + // fmt.Printf("Failed to get password: %v\n", err) + // return nil, common.Address{}, err + //} + + // password:= "qwertyuiop" + + address := common.HexToAddress(addressStr) + err = wallet.Unlock(address, password, nil) + if err != nil { + fmt.Printf("Failed to unlock address %v: %v\n", address.Hex(), err) + return nil, common.Address{}, err + } + + return wallet, address, nil +} + func getWalletType(cmd *cobra.Command) (walletType wtypes.WalletType) { walletTypeStr := cmd.Flag("wallet").Value.String() if walletTypeStr == "nano" { diff --git a/cmd/thetacli/cmd/tx/withdraw_stake.go b/cmd/thetacli/cmd/tx/withdraw_stake.go index 23358623..0e64bc0b 100644 --- a/cmd/thetacli/cmd/tx/withdraw_stake.go +++ b/cmd/thetacli/cmd/tx/withdraw_stake.go @@ -80,6 +80,7 @@ func doWithdrawStakeCmd(cmd *cobra.Command, args []string) { } func init() { + withdrawStakeCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") withdrawStakeCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") withdrawStakeCmd.Flags().StringVar(&sourceFlag, "source", "", "Source of the stake") withdrawStakeCmd.Flags().StringVar(&holderFlag, "holder", "", "Holder of the stake") diff --git a/cmd/thetacli/test/batch.sh b/cmd/thetacli/test/batch.sh index b628e103..4c0162f2 100755 --- a/cmd/thetacli/test/batch.sh +++ b/cmd/thetacli/test/batch.sh @@ -1,11 +1,22 @@ #!/bin/bash #set -x #echo on +do_run=1 # Execute(evaluate) the commands +#do_run=0 # Don't evaluate any commands +do_echo=1 # Echo the commands +#do_echo=0 # Don't echo any commands Alice=2E833968E5bB786Ae419c4d13189fB081Cc43bab Bob=70f587259738cB626A1720Af7038B8DcDb6a42a0 Carol=cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 rid=rid1000001 rpduration=51 +rfund=100 +rcoll=101 +tfuel=50 +bobsigs=1 +carolsigs=1 + +startseq=0 ##################################################################### # Default scale used by float functions. @@ -29,60 +40,117 @@ function un_wei() return $stat } +#cbh=$(thetacli query status | tail -n +2 | jq .current_height) +echo "" +echo "Getting Current Block Height." +#cmd='cat outbin/combined.json | jq '"'"'.contracts | ."'$solfile':'$contractName'" | .abi '"'"' > outbin/abi.json' +cmd='cbh=$(thetacli query status | jq .current_height)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo "current_block_height: "$cbh + +#aib=$(thetacli query account --address=$Alice | tail -n +2 | jq .coins.tfuelwei | tr -d '"'"'"'"'"') +echo "" +echo "Getting Alice's account balance." +cmd='aib=$(thetacli query account --address='$Alice' | jq .coins.tfuelwei | tr -d '"'"'"'"'"')' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo "Alice initial balance: "$(un_wei $aib) -cbh=$(thetacli query status | tail -n +2 | jq .current_height) - -aib=$(thetacli query account --address=$Alice | tail -n +2 | jq .coins.tfuelwei | tr -d '"') -aseq=$(thetacli query account --address=$Alice | tail -n +2 | jq .sequence | tr -d '"') +echo "" +echo "Getting Alice's next sequence." +cmd='aseq=$(thetacli query account --address='$Alice' | jq .sequence | tr -d '"'"'"'"'"')' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi ans=$(( $aseq + 1 )) -echo "Alice initial balance: "$(un_wei $aib) echo "Alice next sequence: "$ans -arf=$(thetacli query account --address=$Alice | tail -n +2 | jq .reserved_funds) + +echo "" +echo "Check for existing reserve fund." +cmd='arf=$(thetacli query account --address='$Alice' | jq .reserved_funds)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi #echo "arf:"${#arf} if [ ${#arf} == 2 ]; then echo "No Reserve Fund" echo "Alice begin create reserve." - ./reserve.sh --from=$Alice --fund=10 --collateral=11 --duration=$rpduration --resource_ids=$rid --seq=$ans - echo "Alice end create reserve." - - exit + cmd='thetacli tx reserve --chain="privatenet" --async --from='$Alice' --fund='$rfund' --collateral='$rcoll' --duration='$rpduration' --resource_ids='$rid' --seq='$ans' --pw=qwertyuiop' + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_run -eq 1 ]; then eval $cmd; fi + echo "Alice end create reserve. Wait 10 seconds and rereun." + echo "Sleeping..." + sleep 10 + #exit else echo "Reserve Fund Exists" #echo "arf:"$arf - ebh=$(echo "$arf" | jq .[0].end_block_height) + ebh=$(echo "$arf" | jq .[0].end_block_height | tr -d '"') + resseq=$(echo "$arf" | jq .[0].reserve_sequence | tr -d '"') + echo "" + echo "reserve_sequence:"$resseq echo "end_block_height:"$ebh - echo "current_block_height:"$(thetacli query status | tail -n +2 | jq .current_height) + echo "current_block_height:"$(thetacli query status | jq .current_height | tr -d '"') fi +#echo "" +#echo "Send Bob 1 TFuel(manually)." +#cmd='thetacli tx send --chain="privatenet" --async --from='$Alice' --to='$Bob' --theta=0 --tfuel='$tfuel' --seq='$ans +#if [ $do_echo -eq 1 ]; then echo $cmd; fi +##if [ $do_run -eq 1 ]; then eval $cmd; fi +#exit -#printf "Alice :%d\n" $aib +#echo "" +#echo "Send Carol 1 TFuel(manually)." +#cmd='thetacli tx send --chain="privatenet" --async --from='$Alice' --to='$Carol' --theta=0 --tfuel='$tfuel' --seq='$ans +#if [ $do_echo -eq 1 ]; then echo $cmd; fi +##if [ $do_run -eq 1 ]; then eval $cmd; fi +#exit -#./send.sh --from=$Alice --to=$Bob --theta=0 --tfuel=1 --seq=$ans - -aab=$(thetacli query account --address=$Alice | tail -n +2 | jq .coins.tfuelwei | tr -d '"') -bab=$(thetacli query account --address=$Bob | tail -n +2 | jq .coins.tfuelwei | tr -d '"') +aab=$(thetacli query account --address=$Alice | jq .coins.tfuelwei | tr -d '"') +bab=$(thetacli query account --address=$Bob | jq .coins.tfuelwei | tr -d '"') +echo "" echo "Alice after balance: "$(un_wei $aab) echo "Bob after balance: "$(un_wei $bab) -aseq=$(thetacli query account --address=$Alice | tail -n +2 | jq .sequence | tr -d '"') + +aib=$(thetacli query account --address=$Alice | jq .coins.tfuelwei | tr -d '"') +bib=$(thetacli query account --address=$Bob | jq .coins.tfuelwei | tr -d '"') +cib=$(thetacli query account --address=$Carol | jq .coins.tfuelwei | tr -d '"') + +aseq=$(thetacli query account --address=$Alice | jq .sequence | tr -d '"') ans=$(( $aseq + 1 )) declare -a sigs +echo "" +echo "Begin off-chain signature generation." +echo "" + +start=`date +%s` + i=0 -bobcnt=1 -while [ $i -lt $bobcnt ]; do - sigout=$(./sp.sh --from=$Alice --to=$Bob --payment_seq=$i --reserve_seq=$ans --resource_id=$rid --tfuel=2 | tail -n +8 | jq .source.signature | tr -d '"') +while [ $i -lt $bobsigs ]; do + echo "i:"$i + payseq=$(( $startseq+$i+1 )) + #cmd='sigout=$(./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$i' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' | tail -n +6 | jq .source.signature | tr -d '"'"'"'"'"')' + cmd='sigout=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' --pw=qwertyuiop | jq .source.signature | tr -d '"'"'"'"'"')' + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_run -eq 1 ]; then eval $cmd; fi sigs+=($sigout) let i++ done -carolcnt=$(( $bobcnt+1 )) -while [ $i -lt $carolcnt ]; do - sigout=$(./sp.sh --from=$Alice --to=$Carol --payment_seq=$i --reserve_seq=$ans --resource_id=$rid --tfuel=2 | tail -n +8 | jq .source.signature | tr -d '"') +i=0 +while [ $i -lt $carolsigs ]; do + echo "i:"$i + payseq=$(( $startseq+$bobsigs+$i+1 )) + #cmd='sigout=$(./sp.sh --from='$Alice' --to='$Carol' --payment_seq='$i' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' | tail -n +6 | jq .source.signature | tr -d '"'"'"'"'"')' + cmd='sigout=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' --pw=qwertyuiop | jq .source.signature | tr -d '"'"'"'"'"')' + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_run -eq 1 ]; then eval $cmd; fi sigs+=($sigout) let i++ done @@ -92,19 +160,74 @@ do echo "SIG:"$sig done +echo "" +echo "End off-chain signature generation." +echo "" + +end=`date +%s` +let deltatime=end-start +let hours=deltatime/3600 +let minutes=(deltatime/60)%60 +let seconds=deltatime%60 +printf "Off-Chain Time spent: %d:%02d:%02d\n" $hours $minutes $seconds + +start=`date +%s` + +echo "" +echo "Begin on-chain service-payment transactions." +echo "" + i=0 -bobcnt=1 -while [ $i -lt $bobcnt ]; do +while [ $i -lt $bobsigs ]; do + #echo "i:"$i sig=${sigs[$i]} - echo "Bob"$i":"$sig - ./sp.sh --from=$Alice --to=$Bob --payment_seq=$i --reserve_seq=$ans --resource_id=$rid --tfuel=2 --on_chain --src_sig=$sig + echo "Bob["$i"]:"$sig + payseq=$(( $startseq+$i+1 )) + #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig + cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' --pw=qwertyuiop --on_chain --src_sig='$sig + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_run -eq 1 ]; then eval $cmd; fi let i++ done -while [ $i -lt $carolcnt ]; do - #sigout=$(./sp.sh --from=$Alice --to=$Bob --payment_seq=$i --reserve_seq=$ans --resource_id=$rid --tfuel=2 | tail -n +8 | jq .source.signature) - #sigs+=($sigout) - echo "Carol"$i":"${sigs[$i]} + +i=0 +while [ $i -lt $carolsigs ]; do + #echo "i:"$i + sig=${sigs[$i+$bobsigs]} + echo "Carol["$i+$bobsigs"]:"$sig + payseq=$(( $startseq+$bobsigs+$i+1 )) + #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig + cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' --pw=qwertyuiop --on_chain --src_sig='$sig + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_run -eq 1 ]; then eval $cmd; fi let i++ done +echo "" +echo "End on-chain service-payment transactions." +echo "" +end=`date +%s` +let deltatime=end-start +let hours=deltatime/3600 +let minutes=(deltatime/60)%60 +let seconds=deltatime%60 +printf "On-Chain Time spent: %d:%02d:%02d\n" $hours $minutes $seconds + + + +aab=$(thetacli query account --address=$Alice | jq .coins.tfuelwei | tr -d '"') +bab=$(thetacli query account --address=$Bob | jq .coins.tfuelwei | tr -d '"') +cab=$(thetacli query account --address=$Carol | jq .coins.tfuelwei | tr -d '"') + +echo "" +echo "Alice initial balance: "$(un_wei $aib) +echo "Alice final balance : "$(un_wei $aab) +echo "" +echo "Bob initial balance : "$(un_wei $bib) +echo "Bob final balance : "$(un_wei $bab) +echo "" +echo "Carol initial balance: "$(un_wei $cib) +echo "Carol final balance : "$(un_wei $cab) +echo "" +echo "Finished Batch Test." \ No newline at end of file diff --git a/cmd/thetacli/test/defaultpw b/cmd/thetacli/test/defaultpw index bea1f091..f04fd8d8 100644 --- a/cmd/thetacli/test/defaultpw +++ b/cmd/thetacli/test/defaultpw @@ -1,2 +1 @@ -qwertyuiop - +qwertyuiop \ No newline at end of file diff --git a/cmd/thetacli/test/reserve.sh b/cmd/thetacli/test/reserve.sh index d4b8dfd9..654aa37b 100755 --- a/cmd/thetacli/test/reserve.sh +++ b/cmd/thetacli/test/reserve.sh @@ -10,6 +10,6 @@ spawn thetacli tx reserve --async --chain="privatenet" $arg1 $arg2 $arg3 $arg4 $ set code [open "./defaultpw" r] set pass [read $code] expect { - password: {send "$pass\r" ; exp_continue} + password: {send "$pass\n" ; exp_continue} eof exit } diff --git a/cmd/thetacli/test/sp.out b/cmd/thetacli/test/sp.out deleted file mode 100644 index 635df76e..00000000 --- a/cmd/thetacli/test/sp.out +++ /dev/null @@ -1,34 +0,0 @@ -spawn thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=3 --resource_id=rid1000001 --tfuel=2 -Using config file: /Users/i830671/.thetacli/config.yaml -Please enter password: qwertyuiop - - - -Off-Chain transaction: -{ - "fee": { - "thetawei": "0", - "tfuelwei": "1000000000000" - }, - "source": { - "address": "0x2e833968e5bb786ae419c4d13189fb081cc43bab", - "coins": { - "thetawei": "0", - "tfuelwei": "2000000000000000000" - }, - "sequence": "1", - "signature": "0x5dc0a9661ad351c3d62e42359e9d514345b40fe93679578efb0140ebd1130d904598892ac5c444e96287855ec2a684cf9ba162b2ffe72feca8540a92f83a9ad500" - }, - "target": { - "address": "0x70f587259738cb626a1720af7038b8dcdb6a42a0", - "coins": { - "thetawei": "0", - "tfuelwei": "2000000000000000000" - }, - "sequence": "0", - "signature": "0x756e7369676e6564" - }, - "payment_sequence": "1", - "reserve_sequence": "3", - "resource_id": "rid1000001" -} From 4754b6f15fbe3bc4641774cdd02155770bae4876 Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Thu, 10 Jun 2021 01:11:33 -0400 Subject: [PATCH 06/20] echo on-chain --- cmd/thetacli/test/batch.sh | 194 +++++++++++++++++++++++++++++++------ 1 file changed, 165 insertions(+), 29 deletions(-) diff --git a/cmd/thetacli/test/batch.sh b/cmd/thetacli/test/batch.sh index 4c0162f2..4cd352c1 100755 --- a/cmd/thetacli/test/batch.sh +++ b/cmd/thetacli/test/batch.sh @@ -2,19 +2,28 @@ #set -x #echo on do_run=1 # Execute(evaluate) the commands #do_run=0 # Don't evaluate any commands -do_echo=1 # Echo the commands -#do_echo=0 # Don't echo any commands +#do_echo=1 # Echo the commands +do_echo=0 # Don't echo any commands +do_echo_on_chain=1 # Echo the on-chain commands +#do_echo_on_chain=0 # Don't echo on-chain commands Alice=2E833968E5bB786Ae419c4d13189fB081Cc43bab Bob=70f587259738cB626A1720Af7038B8DcDb6a42a0 Carol=cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 rid=rid1000001 rpduration=51 -rfund=100 -rcoll=101 -tfuel=50 -bobsigs=1 -carolsigs=1 +rfund=200 +rcoll=201 + +tfuel=2 + +bobsigs=5 +carolsigs=5 + +tfuelfee=0.3 +tfuelperc=0.0 +visaperc=0.0129 +visaflat=0.05 startseq=0 @@ -44,11 +53,128 @@ function un_wei() echo "" echo "Getting Current Block Height." #cmd='cat outbin/combined.json | jq '"'"'.contracts | ."'$solfile':'$contractName'" | .abi '"'"' > outbin/abi.json' -cmd='cbh=$(thetacli query status | jq .current_height)' +cmd='cbh=$(thetacli query status | jq .current_height | tr -d '"'"'"'"'"')' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi echo "current_block_height: "$cbh +echo "" +echo "Getting Current Block Height Timestamp." +#cmd='cat outbin/combined.json | jq '"'"'.contracts | ."'$solfile':'$contractName'" | .abi '"'"' > outbin/abi.json' +cmd='cbt=$(thetacli query block --height='$cbh' | jq .timestamp | tr -d '"'"'"'"'"')' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo "current_timestamp: "$cbt + +echo "" +echo "Getting Block Height-100 Timestamp." +cmd='pbh=$(echo "scale=2; '$cbh' - 100" | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi + +cmd='pbt=$(thetacli query block --height='$pbh' | jq .timestamp | tr -d '"'"'"'"'"')' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo "block-100_timestamp: "$pbt + +# Last 100 block running average seconds per block +cmd='aspb=$(echo "scale=2; ('$cbt' - '$pbt')/100" | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo "average seconds per block: "$aspb + +#// github.com/thetatoken/theta/ledger/types/const.go : Line 85 +# // MaximumFundReserveDuration indicates the maximum duration (in terms of number of blocks) of reserving fund +# MaximumFundReserveDuration uint64 = 12 * 3600 +# +# // MinimumFundReserveDuration indicates the minimum duration (in terms of number of blocks) of reserving fund +# MinimumFundReserveDuration uint64 = 300 +xfdb=43200 +#nfdb=300 My privatenet is overriden to 30 blocks for testing. +nfdb=30 + +let xffrb=$cbh+xfdb # maXimum Future Fund Reserverve Block +let nffrb=$cbh+nfdb # miNimum Future Fund Reserverve Block + +cmd='deltatime=$(echo "scale=0; ('$aspb' "'*'" '$xfdb')/1" | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo "deltatime: "$deltatime + +let hours=deltatime/3600 +let minutes=(deltatime/60)%60 +let seconds=deltatime%60 +printf "Max time until Reserve Deposit Expiration: %d:%02d:%02d\n" $hours $minutes $seconds + +cmd='deltatime=$(echo "scale=0; ('$aspb' "'*'" '$nfdb')/1" | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo "deltatime: "$deltatime + +let hours=deltatime/3600 +let minutes=(deltatime/60)%60 +let seconds=deltatime%60 +printf "Min time until Reserve Deposit Expiration: %d:%02d:%02d\n" $hours $minutes $seconds + +let moviesecs=120*60 # 90mins + 30 for pausing to pee and make popcorn +cmd='deltablocks=$(echo "scale=0; ('$moviesecs' / '$aspb')/1" | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo "deltablocks: "$deltablocks + +echo -n " Current Date-Time : " ; date -r $cbt +#dis=$(date +%s) +cmd='expireatsecs=$(echo "scale=0; ('$cbt' + '$deltatime')/1" | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo -n "Estimated Reserve Expiration: " ; date -r $expireatsecs + +#curl -s https://explorer.thetatoken.org:8443/api/price/all | jq '.body[] | select(._id == "TFUEL") | .price' +tfuelperusd=$(curl -s https://explorer.thetatoken.org:8443/api/price/all | jq '.body[] | select(._id == "TFUEL") | .price') +echo "TFuel(USD): "$tfuelperusd + +cmd='tfuelflat=$(echo "scale=2; (('$tfuelperusd' "'*'" '$tfuelfee') + 0.005)/1" | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo "USD/Transaction: "$tfuelflat + +# https://www.fool.com/the-ascent/research/average-credit-card-processing-fees-costs-america/ +#Visa 1.29% + $0.05 + +#(((tfuel * tfuelperusd * visaperc) + visaflat) * (bobsigs + carlolsigs)) + +#((tfuel * tfuelperusd * tfuelperc) + tfuelflat) * (bobsigs + carlolsigs) + +let totalitems=bobsigs+carolsigs + +cmd='tfuelitemusd=$(echo "scale=2; (('$tfuel' "'*'" '$tfuelperusd') + 0.005)/1 " | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi + +cmd='totalvalue=$(echo "scale=2; (('$tfuelitemusd' "'*'" '$totalitems') + 0.005)/1 " | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo $tfuel" TFuel in USD = "$tfuelitemusd" x "$totalitems" items = "$totalvalue" USD" + + +cmd='visacost=$(echo "scale=2; (((('$tfuel' "'*'" '$tfuelperusd' "'*'" '$visaperc') + '$visaflat') "'*'" '$totalitems') + 0.005)/1 " | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +cmd='visamargin=$(echo "scale=4; (('$visacost' / '$totalvalue') "'*'" 100)" | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo "visacost USD: "$visacost" to send "$totalitems" items ("$visamargin"%)margin" + +cmd='mn30cost=$(echo "scale=2; (((('$tfuel' "'*'" '$tfuelperusd' "'*'" '$tfuelperc') + '$tfuelflat') "'*'" '$totalitems') + 0.005)/1 " | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +cmd='mn30margin=$(echo "scale=4; (('$mn30cost' / '$totalvalue') "'*'" 100)" | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo "mn30cost USD: "$mn30cost" to send "$totalitems" items ("$mn30margin"%)margin" + +#exit + #aib=$(thetacli query account --address=$Alice | tail -n +2 | jq .coins.tfuelwei | tr -d '"'"'"'"'"') echo "" echo "Getting Alice's account balance." @@ -65,6 +191,20 @@ if [ $do_run -eq 1 ]; then eval $cmd; fi ans=$(( $aseq + 1 )) echo "Alice next sequence: "$ans +#echo "" +#echo "Send Bob 1 TFuel(manually)." +#cmd='thetacli tx send --chain="privatenet" --async --from='$Alice' --to='$Bob' --theta=0 --tfuel=1 --seq='$ans +#if [ $do_echo -eq 1 ]; then echo $cmd; fi +#if [ $do_run -eq 1 ]; then eval $cmd; fi +#exit + +#echo "" +#echo "Send Carol 1 TFuel(manually)." +#cmd='thetacli tx send --chain="privatenet" --async --from='$Alice' --to='$Carol' --theta=0 --tfuel=1 --seq='$ans +#if [ $do_echo -eq 1 ]; then echo $cmd; fi +#if [ $do_run -eq 1 ]; then eval $cmd; fi +#exit + echo "" echo "Check for existing reserve fund." cmd='arf=$(thetacli query account --address='$Alice' | jq .reserved_funds)' @@ -79,10 +219,10 @@ if [ ${#arf} == 2 ]; then cmd='thetacli tx reserve --chain="privatenet" --async --from='$Alice' --fund='$rfund' --collateral='$rcoll' --duration='$rpduration' --resource_ids='$rid' --seq='$ans' --pw=qwertyuiop' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi - echo "Alice end create reserve. Wait 10 seconds and rereun." + echo "Alice end create reserve. Wait 15 seconds and rereun." echo "Sleeping..." - sleep 10 - #exit + sleep 15 + exit else echo "Reserve Fund Exists" #echo "arf:"$arf @@ -94,20 +234,6 @@ else echo "current_block_height:"$(thetacli query status | jq .current_height | tr -d '"') fi -#echo "" -#echo "Send Bob 1 TFuel(manually)." -#cmd='thetacli tx send --chain="privatenet" --async --from='$Alice' --to='$Bob' --theta=0 --tfuel='$tfuel' --seq='$ans -#if [ $do_echo -eq 1 ]; then echo $cmd; fi -##if [ $do_run -eq 1 ]; then eval $cmd; fi -#exit - -#echo "" -#echo "Send Carol 1 TFuel(manually)." -#cmd='thetacli tx send --chain="privatenet" --async --from='$Alice' --to='$Carol' --theta=0 --tfuel='$tfuel' --seq='$ans -#if [ $do_echo -eq 1 ]; then echo $cmd; fi -##if [ $do_run -eq 1 ]; then eval $cmd; fi -#exit - aab=$(thetacli query account --address=$Alice | jq .coins.tfuelwei | tr -d '"') bab=$(thetacli query account --address=$Bob | jq .coins.tfuelwei | tr -d '"') @@ -181,12 +307,17 @@ i=0 while [ $i -lt $bobsigs ]; do #echo "i:"$i sig=${sigs[$i]} - echo "Bob["$i"]:"$sig payseq=$(( $startseq+$i+1 )) + echo "Bob["$payseq"]" #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' --pw=qwertyuiop --on_chain --src_sig='$sig if [ $do_echo -eq 1 ]; then echo $cmd; fi - if [ $do_run -eq 1 ]; then eval $cmd; fi + if [ $do_echo_on_chain -eq 1 ]; then + echo $cmd + echo "" + else + if [ $do_run -eq 1 ]; then eval $cmd; fi + fi let i++ done @@ -194,12 +325,17 @@ i=0 while [ $i -lt $carolsigs ]; do #echo "i:"$i sig=${sigs[$i+$bobsigs]} - echo "Carol["$i+$bobsigs"]:"$sig payseq=$(( $startseq+$bobsigs+$i+1 )) + echo "Carol["$payseq"]" #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' --pw=qwertyuiop --on_chain --src_sig='$sig if [ $do_echo -eq 1 ]; then echo $cmd; fi - if [ $do_run -eq 1 ]; then eval $cmd; fi + if [ $do_echo_on_chain -eq 1 ]; then + echo $cmd + echo "" + else + if [ $do_run -eq 1 ]; then eval $cmd; fi + fi let i++ done From e330879a255837b152538fe1e969235b1eb63124 Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Fri, 11 Jun 2021 13:01:10 -0400 Subject: [PATCH 07/20] WSJ example --- cmd/thetacli/test/batch.sh | 220 ++++++++++++++++++++++++++++++++----- 1 file changed, 195 insertions(+), 25 deletions(-) diff --git a/cmd/thetacli/test/batch.sh b/cmd/thetacli/test/batch.sh index 4cd352c1..976e41af 100755 --- a/cmd/thetacli/test/batch.sh +++ b/cmd/thetacli/test/batch.sh @@ -11,14 +11,111 @@ Alice=2E833968E5bB786Ae419c4d13189fB081Cc43bab Bob=70f587259738cB626A1720Af7038B8DcDb6a42a0 Carol=cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 rid=rid1000001 -rpduration=51 -rfund=200 -rcoll=201 -tfuel=2 +rpduration=101 -bobsigs=5 -carolsigs=5 +rfund=100 +rcoll=101 + +# Cost tests performed at Thu Jun 10 13:17:06 EDT 2021 +#tfuel=100.0 +#Thu Jun 10 13:19:07 EDT 2021 +#TFuel(USD): 0.54810887040421 +#USD/Transaction: .16 +#100.0 TFuel in USD = 54.8109 x 10 items = 548.1090 USD +#visacost USD: 7.57 to send 10 items (1.3800%)margin +#mn30cost USD: 1.60 to send 10 items (.2900%)margin +# +#tfuel=10.0 +#Thu Jun 10 13:19:40 EDT 2021 +#TFuel(USD): 0.54810887040421 +#USD/Transaction: .16 +#10.0 TFuel in USD = 5.4811 x 10 items = 54.8110 USD +#visacost USD: 1.21 to send 10 items (2.2000%)margin +#mn30cost USD: 1.60 to send 10 items (2.9100%)margin +# +#tfuel=1.0 +#Thu Jun 10 13:20:36 EDT 2021 +#TFuel(USD): 0.54810887040421 +#USD/Transaction: .16 +#1.0 TFuel in USD = .5481 x 10 items = 5.4810 USD +#visacost USD: .57 to send 10 items (10.3900%)margin +#mn30cost USD: 1.60 to send 10 items (29.1900%)margin +# +#tfuel=0.1 +#Thu Jun 10 13:21:20 EDT 2021 +#TFuel(USD): 0.54810887040421 +#USD/Transaction: .16 +#0.1 TFuel in USD = .0548 x 10 items = .5480 USD +#visacost USD: .51 to send 10 items (93.0600%)margin +#mn30cost USD: 1.60 to send 10 items (291.9700%)margin +# +#tfuel=0.01 +#Thu Jun 10 13:22:17 EDT 2021 +#TFuel(USD): 0.55011933917353 +#USD/Transaction: .17 +#0.01 TFuel in USD = .0055 x 10 items = .0550 USD +#visacost USD: .50 to send 10 items (909.0900%)margin +#mn30cost USD: 1.70 to send 10 items (3090.9000%)margin +# +# Now these are off-chain micropayment scenarios +# performed Fri Jun 11 11:56:06 EDT 2021 +# +#Fri Jun 11 11:56:06 EDT 2021 +#TFuel(USD): 0.48622932399761 +#USD/Transaction: .15 +#0.01 TFuel in USD = .0049 x 1000 items = 4.9000 USD +#visacost USD: 50.06 to send 1000 items (1021.6300%)margin +#mn30cost USD: 150.00 to send 1000 items (3061.2200%)margin +#mn30cost USD: .15 to send 1000 items (3.061200%)margin(1 service_payment) +# +#Fri Jun 11 11:58:38 EDT 2021 +#TFuel(USD): 0.48603013940903 +#USD/Transaction: .15 +#0.001 TFuel in USD = .0005 x 10000 items = 5.0000 USD +#visacost USD: 500.06 to send 10000 items (10001.2000%)margin +#mn30cost USD: 1500.00 to send 10000 items (30000.0000%)margin +#mn30cost USD: .15 to send 10000 items (3.000000%)margin(1 service_payment) +# +# WSJ.com example : $38.99 for 4 weeks = $1.3925 per day = $4.1775 per 3 days +# Subscriber reads 10 articles over 3 days on average. Each article Header + blurb free +# Once article clicked on. First min charged, additional min/read charged as scrolled to : avg 5 mins/article +# 10 article * 5 min/read/article = 50 transactions over 3 days. +# If subsriber clicks on 0 articles over 3 days, no charges for that time +# Once user clicks on next article, new reserve fund is created for next 3 days +# +#Fri Jun 11 12:22:15 EDT 2021 +#TFuel(USD): 0.48705293232693 +#USD/Transaction: .15 +#0.2 TFuel in USD = .0974 x 50 items = 4.8700 USD +#visacost USD: 2.56 to send 50 items (52.5600%)margin +#mn30cost USD: 7.50 to send 50 items (154.0000%)margin +#mn30cost USD: .15 to send 50 items (3.080000%)margin(1 service_payment) +# +# Daily Reader 3-4 articles/day +# 4.8700+0.15 x 10(3day periods/month) = $48.85/month +# +# Weekend Reader +# 4.8700+0.15 x 4(3day periods/month) = $19.54/month +# +# Sporatic Reader : 2 articles/day on 10 days spread evenly across the month +# 0.963+0.15 x 10 = $9.78/month +# +# Occasional Reader : 4 articles/month spread evenly across the month +# 0.4815+0.15 x 4 = $2.53/month +# +# Rare Reader : 1 article/month +# 0.4815+0.15 x 1 = $0.63/month +# +# Rare Reader Aborted Article : 1/5 article/month +# 0.0963+0.15 x 1 = $0.25/month + + +tfuel=0.2 + +# total 10 items +bobsigs=10 +carolsigs=0 tfuelfee=0.3 tfuelperc=0.0 @@ -26,6 +123,7 @@ visaperc=0.0129 visaflat=0.05 startseq=0 +accumulate=1 ##################################################################### # Default scale used by float functions. @@ -67,18 +165,18 @@ if [ $do_run -eq 1 ]; then eval $cmd; fi echo "current_timestamp: "$cbt echo "" -echo "Getting Block Height-100 Timestamp." -cmd='pbh=$(echo "scale=2; '$cbh' - 100" | bc -q 2>/dev/null)' +echo "Getting Block Height-10 Timestamp." +cmd='pbh=$(echo "scale=2; '$cbh' - 10" | bc -q 2>/dev/null)' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi cmd='pbt=$(thetacli query block --height='$pbh' | jq .timestamp | tr -d '"'"'"'"'"')' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi -echo "block-100_timestamp: "$pbt +echo "block-10_timestamp: "$pbt -# Last 100 block running average seconds per block -cmd='aspb=$(echo "scale=2; ('$cbt' - '$pbt')/100" | bc -q 2>/dev/null)' +# Last 10 block running average seconds per block +cmd='aspb=$(echo "scale=2; ('$cbt' - '$pbt')/10" | bc -q 2>/dev/null)' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi echo "average seconds per block: "$aspb @@ -129,10 +227,18 @@ if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi echo -n "Estimated Reserve Expiration: " ; date -r $expireatsecs +echo "" + +date + +#https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md #curl -s https://explorer.thetatoken.org:8443/api/price/all | jq '.body[] | select(._id == "TFUEL") | .price' tfuelperusd=$(curl -s https://explorer.thetatoken.org:8443/api/price/all | jq '.body[] | select(._id == "TFUEL") | .price') echo "TFuel(USD): "$tfuelperusd +#curl -s curl https://explorer.thetatoken.org:8443/api/supply/tfuel | jq . + + cmd='tfuelflat=$(echo "scale=2; (('$tfuelperusd' "'*'" '$tfuelfee') + 0.005)/1" | bc -q 2>/dev/null)' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi @@ -147,11 +253,11 @@ echo "USD/Transaction: "$tfuelflat let totalitems=bobsigs+carolsigs -cmd='tfuelitemusd=$(echo "scale=2; (('$tfuel' "'*'" '$tfuelperusd') + 0.005)/1 " | bc -q 2>/dev/null)' +cmd='tfuelitemusd=$(echo "scale=4; (('$tfuel' "'*'" '$tfuelperusd') + 0.00005)/1 " | bc -q 2>/dev/null)' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi -cmd='totalvalue=$(echo "scale=2; (('$tfuelitemusd' "'*'" '$totalitems') + 0.005)/1 " | bc -q 2>/dev/null)' +cmd='totalvalue=$(echo "scale=4; (('$tfuelitemusd' "'*'" '$totalitems') + 0.00005)/1 " | bc -q 2>/dev/null)' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi echo $tfuel" TFuel in USD = "$tfuelitemusd" x "$totalitems" items = "$totalvalue" USD" @@ -173,6 +279,14 @@ if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi echo "mn30cost USD: "$mn30cost" to send "$totalitems" items ("$mn30margin"%)margin" +cmd='mn30cost=$(echo "scale=2; (((('$tfuel' "'*'" '$tfuelperusd' "'*'" '$tfuelperc') "'*'" '$totalitems') + '$tfuelflat') + 0.005)/1 " | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +cmd='mn30margin=$(echo "scale=6; (('$mn30cost' / '$totalvalue') "'*'" 100)" | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +echo "mn30cost USD: "$mn30cost" to send "$totalitems" items ("$mn30margin"%)margin(1 service_payment)" + #exit #aib=$(thetacli query account --address=$Alice | tail -n +2 | jq .coins.tfuelwei | tr -d '"'"'"'"'"') @@ -258,33 +372,53 @@ echo "" start=`date +%s` i=0 +tfuelamt=0 while [ $i -lt $bobsigs ]; do - echo "i:"$i + echo "Alice <=="$tfuel"== Bob" payseq=$(( $startseq+$i+1 )) + if [ $accumulate -eq 1 ]; then + cmd='tfuelamt=$(echo "scale=3; ('$tfuelamt' + '$tfuel')/1" | bc -q 2>/dev/null)' + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_run -eq 1 ]; then eval $cmd; fi + else + tfuelamt=$tfuel + fi + echo "Bob:"$payseq" = "$tfuelamt #cmd='sigout=$(./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$i' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' | tail -n +6 | jq .source.signature | tr -d '"'"'"'"'"')' - cmd='sigout=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' --pw=qwertyuiop | jq .source.signature | tr -d '"'"'"'"'"')' + cmd='sigout=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --pw=qwertyuiop | jq .source.signature | tr -d '"'"'"'"'"')' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi sigs+=($sigout) + echo "" let i++ done i=0 +tfuelamt=0 while [ $i -lt $carolsigs ]; do - echo "i:"$i + echo "Alice <=="$tfuel"== Carol" payseq=$(( $startseq+$bobsigs+$i+1 )) + if [ $accumulate -eq 1 ]; then + cmd='tfuelamt=$(echo "scale=3; ('$tfuelamt' + '$tfuel')/1" | bc -q 2>/dev/null)' + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_run -eq 1 ]; then eval $cmd; fi + else + tfuelamt=$tfuel + fi + echo "Carol:"$payseq" = "$tfuelamt #cmd='sigout=$(./sp.sh --from='$Alice' --to='$Carol' --payment_seq='$i' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' | tail -n +6 | jq .source.signature | tr -d '"'"'"'"'"')' - cmd='sigout=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' --pw=qwertyuiop | jq .source.signature | tr -d '"'"'"'"'"')' + cmd='sigout=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --pw=qwertyuiop | jq .source.signature | tr -d '"'"'"'"'"')' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi sigs+=($sigout) + echo "" let i++ done -for sig in "${sigs[@]}" -do - echo "SIG:"$sig -done +#for sig in "${sigs[@]}" +#do +# echo "SIG:"$sig +#done echo "" echo "End off-chain signature generation." @@ -304,13 +438,31 @@ echo "Begin on-chain service-payment transactions." echo "" i=0 +tfuelamt=0 +let holdcnt=bobsigs-1 while [ $i -lt $bobsigs ]; do #echo "i:"$i sig=${sigs[$i]} payseq=$(( $startseq+$i+1 )) - echo "Bob["$payseq"]" + if [ $accumulate -eq 1 ]; then + cmd='tfuelamt=$(echo "scale=3; ('$tfuelamt' + '$tfuel')/1" | bc -q 2>/dev/null)' + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_run -eq 1 ]; then eval $cmd; fi + else + tfuelamt=$tfuel + fi + if [ $accumulate -eq 1 ]; then + if [ $i -lt $holdcnt ]; then + echo "Hold::: Bob["$payseq"]" + else + echo "Submit: Bob["$payseq"]" + fi + else + echo "Bob["$payseq"]" + fi + #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig - cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' --pw=qwertyuiop --on_chain --src_sig='$sig + cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --pw=qwertyuiop --on_chain --src_sig='$sig if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_echo_on_chain -eq 1 ]; then echo $cmd @@ -322,13 +474,31 @@ while [ $i -lt $bobsigs ]; do done i=0 +tfuelamt=0 +let holdcnt=carolsigs-1 while [ $i -lt $carolsigs ]; do #echo "i:"$i sig=${sigs[$i+$bobsigs]} payseq=$(( $startseq+$bobsigs+$i+1 )) - echo "Carol["$payseq"]" + if [ $accumulate -eq 1 ]; then + cmd='tfuelamt=$(echo "scale=3; ('$tfuelamt' + '$tfuel')/1" | bc -q 2>/dev/null)' + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_run -eq 1 ]; then eval $cmd; fi + else + tfuelamt=$tfuel + fi + if [ $accumulate -eq 1 ]; then + if [ $i -lt $holdcnt ]; then + echo "Hold::: Carol["$payseq"]" + else + echo "Submit: Carol["$payseq"]" + fi + else + echo "Carol["$payseq"]" + fi + #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig - cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' --pw=qwertyuiop --on_chain --src_sig='$sig + cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --pw=qwertyuiop --on_chain --src_sig='$sig if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_echo_on_chain -eq 1 ]; then echo $cmd From f931680d89743b7a4a890cece604b4529a18633f Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Fri, 11 Jun 2021 18:51:37 -0400 Subject: [PATCH 08/20] added next sequence --- cmd/thetacli/test/TEST_RESULTS.md | 112 ++++++++++++++ cmd/thetacli/test/batch.sh | 236 ++++++++++++------------------ 2 files changed, 207 insertions(+), 141 deletions(-) create mode 100644 cmd/thetacli/test/TEST_RESULTS.md diff --git a/cmd/thetacli/test/TEST_RESULTS.md b/cmd/thetacli/test/TEST_RESULTS.md new file mode 100644 index 00000000..551f00c6 --- /dev/null +++ b/cmd/thetacli/test/TEST_RESULTS.md @@ -0,0 +1,112 @@ +## Test Results + +### Cost tests performed at Thu Jun 10 13:17:06 EDT 2021 +``` +tfuel=100.0 +Thu Jun 10 13:19:07 EDT 2021 +TFuel(USD): 0.54810887040421 +USD/Transaction: .16 +100.0 TFuel in USD = 54.8109 x 10 items = 548.1090 USD +visacost USD: 7.57 to send 10 items (1.3800%)margin +mn30cost USD: 1.60 to send 10 items (.2900%)margin +``` +``` +tfuel=10.0 +Thu Jun 10 13:19:40 EDT 2021 +TFuel(USD): 0.54810887040421 +USD/Transaction: .16 +10.0 TFuel in USD = 5.4811 x 10 items = 54.8110 USD +visacost USD: 1.21 to send 10 items (2.2000%)margin +mn30cost USD: 1.60 to send 10 items (2.9100%)margin +``` +``` +tfuel=1.0 +Thu Jun 10 13:20:36 EDT 2021 +TFuel(USD): 0.54810887040421 +USD/Transaction: .16 +1.0 TFuel in USD = .5481 x 10 items = 5.4810 USD +visacost USD: .57 to send 10 items (10.3900%)margin +mn30cost USD: 1.60 to send 10 items (29.1900%)margin +``` +``` +tfuel=0.1 +Thu Jun 10 13:21:20 EDT 2021 +TFuel(USD): 0.54810887040421 +USD/Transaction: .16 +0.1 TFuel in USD = .0548 x 10 items = .5480 USD +visacost USD: .51 to send 10 items (93.0600%)margin +mn30cost USD: 1.60 to send 10 items (291.9700%)margin +``` +``` +tfuel=0.01 +Thu Jun 10 13:22:17 EDT 2021 +TFuel(USD): 0.55011933917353 +USD/Transaction: .17 +0.01 TFuel in USD = .0055 x 10 items = .0550 USD +visacost USD: .50 to send 10 items (909.0900%)margin +mn30cost USD: 1.70 to send 10 items (3090.9000%)margin +``` +### Now these are off-chain micropayment scenarios +### performed Fri Jun 11 11:56:06 EDT 2021 +``` +Fri Jun 11 11:56:06 EDT 2021 +TFuel(USD): 0.48622932399761 +USD/Transaction: .15 +0.01 TFuel in USD = .0049 x 1000 items = 4.9000 USD +visacost USD: 50.06 to send 1000 items (1021.6300%)margin +mn30cost USD: 150.00 to send 1000 items (3061.2200%)margin +mn30cost USD: .15 to send 1000 items (3.061200%)margin(1 service_payment) +``` +``` +Fri Jun 11 11:58:38 EDT 2021 +TFuel(USD): 0.48603013940903 +USD/Transaction: .15 +0.001 TFuel in USD = .0005 x 10000 items = 5.0000 USD +visacost USD: 500.06 to send 10000 items (10001.2000%)margin +mn30cost USD: 1500.00 to send 10000 items (30000.0000%)margin +mn30cost USD: .15 to send 10000 items (3.000000%)margin(1 service_payment) +``` +### Online newspaper use-case +#### Assumptions: +``` + WSJ.com example : $38.99 for 4 weeks = $1.3925 per day = $4.1775 per 3 days + Subscriber reads 10 articles over 3 days on average. Each article Header + blurb free + Once article clicked on. First min charged, additional min/read charged as scrolled to : avg 5 mins/article + 10 article * 5 min/read/article = 50 transactions over 3 days. + If subsriber clicks on 0 articles over 3 days, no charges for that time + Once user clicks on next article, new reserve fund is created for next 3 days +``` + +``` +Fri Jun 11 12:22:15 EDT 2021 +TFuel(USD): 0.48705293232693 +USD/Transaction: .15 +0.2 TFuel in USD = .0974 x 50 items = 4.8700 USD +visacost USD: 2.56 to send 50 items (52.5600%)margin +mn30cost USD: 7.50 to send 50 items (154.0000%)margin +mn30cost USD: .15 to send 50 items (3.080000%)margin(1 service_payment) +``` +Daily Reader 3-4 articles/day +``` +4.8700+0.15 x 10(3day periods/month) = $48.85/month +``` +Weekend Reader +``` +4.8700+0.15 x 4(3day periods/month) = $19.54/month +``` +Sporatic Reader : 2 articles/day on 10 days spread evenly across the month +``` +0.963+0.15 x 10 = $9.78/month +``` +Occasional Reader : 4 articles/month spread evenly across the month +``` +0.4815+0.15 x 4 = $2.53/month +``` +Rare Reader : 1 article/month +``` +0.4815+0.15 x 1 = $0.63/month +``` +Rare Reader Aborted Article : 1/5 article/month +``` +0.0963+0.15 x 1 = $0.25/month +``` \ No newline at end of file diff --git a/cmd/thetacli/test/batch.sh b/cmd/thetacli/test/batch.sh index 976e41af..05f28077 100755 --- a/cmd/thetacli/test/batch.sh +++ b/cmd/thetacli/test/batch.sh @@ -4,118 +4,32 @@ do_run=1 # Execute(evaluate) the commands #do_run=0 # Don't evaluate any commands #do_echo=1 # Echo the commands do_echo=0 # Don't echo any commands -do_echo_on_chain=1 # Echo the on-chain commands -#do_echo_on_chain=0 # Don't echo on-chain commands +#do_echo_on_chain=1 # Echo the on-chain commands +do_echo_on_chain=0 # Don't echo, actually execute on-chain commands +#calc_costs_only=1 # Only calculate the costs +calc_costs_only=0 # Calculate the costs then run tx Alice=2E833968E5bB786Ae419c4d13189fB081Cc43bab Bob=70f587259738cB626A1720Af7038B8DcDb6a42a0 Carol=cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 rid=rid1000001 -rpduration=101 +#rfdurationblocks=101 # Reserve Fund Duration in blocktimes : usualy (101 x 6secs) = 606 / 60 = 10.1 minutes +rfdurationblocks=30 # Reserve Fund Duration in blocktimes : Minimum for testing = 30 = 3 minues +#rfdurationsecs=0 # Reserve Fund Duration in seconds : 0 = Use rfdurationblocks instead +#let rfdurationsecs=120 # Reserve Fund Duration in seconds +let rfdurationsecs=10*60 # 10 minutes +#let rfdurationsecs=3*60*60 # 3 hours rfund=100 rcoll=101 -# Cost tests performed at Thu Jun 10 13:17:06 EDT 2021 -#tfuel=100.0 -#Thu Jun 10 13:19:07 EDT 2021 -#TFuel(USD): 0.54810887040421 -#USD/Transaction: .16 -#100.0 TFuel in USD = 54.8109 x 10 items = 548.1090 USD -#visacost USD: 7.57 to send 10 items (1.3800%)margin -#mn30cost USD: 1.60 to send 10 items (.2900%)margin -# -#tfuel=10.0 -#Thu Jun 10 13:19:40 EDT 2021 -#TFuel(USD): 0.54810887040421 -#USD/Transaction: .16 -#10.0 TFuel in USD = 5.4811 x 10 items = 54.8110 USD -#visacost USD: 1.21 to send 10 items (2.2000%)margin -#mn30cost USD: 1.60 to send 10 items (2.9100%)margin -# -#tfuel=1.0 -#Thu Jun 10 13:20:36 EDT 2021 -#TFuel(USD): 0.54810887040421 -#USD/Transaction: .16 -#1.0 TFuel in USD = .5481 x 10 items = 5.4810 USD -#visacost USD: .57 to send 10 items (10.3900%)margin -#mn30cost USD: 1.60 to send 10 items (29.1900%)margin -# #tfuel=0.1 -#Thu Jun 10 13:21:20 EDT 2021 -#TFuel(USD): 0.54810887040421 -#USD/Transaction: .16 -#0.1 TFuel in USD = .0548 x 10 items = .5480 USD -#visacost USD: .51 to send 10 items (93.0600%)margin -#mn30cost USD: 1.60 to send 10 items (291.9700%)margin -# -#tfuel=0.01 -#Thu Jun 10 13:22:17 EDT 2021 -#TFuel(USD): 0.55011933917353 -#USD/Transaction: .17 -#0.01 TFuel in USD = .0055 x 10 items = .0550 USD -#visacost USD: .50 to send 10 items (909.0900%)margin -#mn30cost USD: 1.70 to send 10 items (3090.9000%)margin -# -# Now these are off-chain micropayment scenarios -# performed Fri Jun 11 11:56:06 EDT 2021 -# -#Fri Jun 11 11:56:06 EDT 2021 -#TFuel(USD): 0.48622932399761 -#USD/Transaction: .15 -#0.01 TFuel in USD = .0049 x 1000 items = 4.9000 USD -#visacost USD: 50.06 to send 1000 items (1021.6300%)margin -#mn30cost USD: 150.00 to send 1000 items (3061.2200%)margin -#mn30cost USD: .15 to send 1000 items (3.061200%)margin(1 service_payment) -# -#Fri Jun 11 11:58:38 EDT 2021 -#TFuel(USD): 0.48603013940903 -#USD/Transaction: .15 -#0.001 TFuel in USD = .0005 x 10000 items = 5.0000 USD -#visacost USD: 500.06 to send 10000 items (10001.2000%)margin -#mn30cost USD: 1500.00 to send 10000 items (30000.0000%)margin -#mn30cost USD: .15 to send 10000 items (3.000000%)margin(1 service_payment) -# -# WSJ.com example : $38.99 for 4 weeks = $1.3925 per day = $4.1775 per 3 days -# Subscriber reads 10 articles over 3 days on average. Each article Header + blurb free -# Once article clicked on. First min charged, additional min/read charged as scrolled to : avg 5 mins/article -# 10 article * 5 min/read/article = 50 transactions over 3 days. -# If subsriber clicks on 0 articles over 3 days, no charges for that time -# Once user clicks on next article, new reserve fund is created for next 3 days -# -#Fri Jun 11 12:22:15 EDT 2021 -#TFuel(USD): 0.48705293232693 -#USD/Transaction: .15 -#0.2 TFuel in USD = .0974 x 50 items = 4.8700 USD -#visacost USD: 2.56 to send 50 items (52.5600%)margin -#mn30cost USD: 7.50 to send 50 items (154.0000%)margin -#mn30cost USD: .15 to send 50 items (3.080000%)margin(1 service_payment) -# -# Daily Reader 3-4 articles/day -# 4.8700+0.15 x 10(3day periods/month) = $48.85/month -# -# Weekend Reader -# 4.8700+0.15 x 4(3day periods/month) = $19.54/month -# -# Sporatic Reader : 2 articles/day on 10 days spread evenly across the month -# 0.963+0.15 x 10 = $9.78/month -# -# Occasional Reader : 4 articles/month spread evenly across the month -# 0.4815+0.15 x 4 = $2.53/month -# -# Rare Reader : 1 article/month -# 0.4815+0.15 x 1 = $0.63/month -# -# Rare Reader Aborted Article : 1/5 article/month -# 0.0963+0.15 x 1 = $0.25/month - - -tfuel=0.2 +tfuel=2 # total 10 items bobsigs=10 -carolsigs=0 +carolsigs=10 tfuelfee=0.3 tfuelperc=0.0 @@ -218,7 +132,7 @@ let moviesecs=120*60 # 90mins + 30 for pausing to pee and make popcorn cmd='deltablocks=$(echo "scale=0; ('$moviesecs' / '$aspb')/1" | bc -q 2>/dev/null)' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi -echo "deltablocks: "$deltablocks +echo "deltablocks: "$deltablocks" to watch a movie." echo -n " Current Date-Time : " ; date -r $cbt #dis=$(date +%s) @@ -287,7 +201,7 @@ if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi echo "mn30cost USD: "$mn30cost" to send "$totalitems" items ("$mn30margin"%)margin(1 service_payment)" -#exit +if [ $calc_costs_only -eq 1 ]; then echo ""; exit; fi #aib=$(thetacli query account --address=$Alice | tail -n +2 | jq .coins.tfuelwei | tr -d '"'"'"'"'"') echo "" @@ -330,7 +244,15 @@ if [ $do_run -eq 1 ]; then eval $cmd; fi if [ ${#arf} == 2 ]; then echo "No Reserve Fund" echo "Alice begin create reserve." - cmd='thetacli tx reserve --chain="privatenet" --async --from='$Alice' --fund='$rfund' --collateral='$rcoll' --duration='$rpduration' --resource_ids='$rid' --seq='$ans' --pw=qwertyuiop' + if [ $rfdurationsecs -eq 0 ]; then + echo "Using "$rfdurationblocks" blocks" + else + cmd='rfdurationblocks=$(echo "scale=0; ('$rfdurationsecs' / '$aspb')/1" | bc -q 2>/dev/null)' + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_run -eq 1 ]; then eval $cmd; fi + echo "Using: "$rfdurationblocks" blocks = "$rfdurationsecs"secs" + fi + cmd='thetacli tx reserve --chain="privatenet" --async --from='$Alice' --fund='$rfund' --collateral='$rcoll' --duration='$rfdurationblocks' --resource_ids='$rid' --seq='$ans' --pw=qwertyuiop' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi echo "Alice end create reserve. Wait 15 seconds and rereun." @@ -346,20 +268,32 @@ else echo "reserve_sequence:"$resseq echo "end_block_height:"$ebh echo "current_block_height:"$(thetacli query status | jq .current_height | tr -d '"') + # Find the largest existing transfer_record sequence number + # thetacli query account --address=2E833968E5bB786Ae419c4d13189fB081Cc43bab | jq .reserved_funds[0].transfer_records[-1].service_payment.payment_sequence | tr -d '"' + cmd='txlen=$(thetacli query account --address='$Alice' | jq .reserved_funds[0].transfer_records)' + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_run -eq 1 ]; then eval $cmd; fi + if [ ${#txlen} == 2 ]; then + echo "No Transfer Records exit yet." + else + echo "Transfer Records exit." + cmd='letxseq=$(thetacli query account --address='$Alice' | jq .reserved_funds[0].transfer_records[-1].service_payment.payment_sequence | tr -d '"'"'"'"'"')' + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_run -eq 1 ]; then eval $cmd; fi + startseq=$letxseq + echo "Setting startseq = "$letxseq + fi fi - -aab=$(thetacli query account --address=$Alice | jq .coins.tfuelwei | tr -d '"') -bab=$(thetacli query account --address=$Bob | jq .coins.tfuelwei | tr -d '"') - -echo "" -echo "Alice after balance: "$(un_wei $aab) -echo "Bob after balance: "$(un_wei $bab) - - aib=$(thetacli query account --address=$Alice | jq .coins.tfuelwei | tr -d '"') bib=$(thetacli query account --address=$Bob | jq .coins.tfuelwei | tr -d '"') cib=$(thetacli query account --address=$Carol | jq .coins.tfuelwei | tr -d '"') +echo "" +echo "Alice init balance: "$(un_wei $aib) +echo "Bob init balance: "$(un_wei $bib) +echo "Carol init balance: "$(un_wei $cib) + + aseq=$(thetacli query account --address=$Alice | jq .sequence | tr -d '"') ans=$(( $aseq + 1 )) @@ -369,7 +303,7 @@ echo "" echo "Begin off-chain signature generation." echo "" -start=`date +%s` +offstart=`date +%s` i=0 tfuelamt=0 @@ -406,7 +340,7 @@ while [ $i -lt $carolsigs ]; do tfuelamt=$tfuel fi echo "Carol:"$payseq" = "$tfuelamt - #cmd='sigout=$(./sp.sh --from='$Alice' --to='$Carol' --payment_seq='$i' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' | tail -n +6 | jq .source.signature | tr -d '"'"'"'"'"')' + #cmd='sigout=$(./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$i' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' | tail -n +6 | jq .source.signature | tr -d '"'"'"'"'"')' cmd='sigout=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --pw=qwertyuiop | jq .source.signature | tr -d '"'"'"'"'"')' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi @@ -424,14 +358,17 @@ echo "" echo "End off-chain signature generation." echo "" -end=`date +%s` -let deltatime=end-start +offend=`date +%s` +let deltatime=offend-offstart let hours=deltatime/3600 let minutes=(deltatime/60)%60 let seconds=deltatime%60 -printf "Off-Chain Time spent: %d:%02d:%02d\n" $hours $minutes $seconds +cmd='secspertx=$(echo "scale=3; ('$deltatime' / ('$bobsigs' + '$carolsigs'))/1" | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +printf "Off-Chain Time spent: %d:%02d:%02d (%2.5f sec/tx)\n" $hours $minutes $seconds $secspertx -start=`date +%s` +onstart=`date +%s` echo "" echo "Begin on-chain service-payment transactions." @@ -439,6 +376,7 @@ echo "" i=0 tfuelamt=0 +baccum=0 let holdcnt=bobsigs-1 while [ $i -lt $bobsigs ]; do #echo "i:"$i @@ -451,30 +389,33 @@ while [ $i -lt $bobsigs ]; do else tfuelamt=$tfuel fi + + #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig + cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --pw=qwertyuiop --on_chain --src_sig='$sig + if [ $accumulate -eq 1 ]; then if [ $i -lt $holdcnt ]; then echo "Hold::: Bob["$payseq"]" + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_echo_on_chain -eq 1 ]; then echo $cmd; echo ""; fi else echo "Submit: Bob["$payseq"]" - fi + let baccum++ + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_echo_on_chain -eq 1 ]; then echo $cmd; echo ""; else if [ $do_run -eq 1 ]; then eval $cmd; fi fi + fi else echo "Bob["$payseq"]" + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_echo_on_chain -eq 1 ]; then echo $cmd; echo ""; else if [ $do_run -eq 1 ]; then eval $cmd; fi fi fi - #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig - cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --pw=qwertyuiop --on_chain --src_sig='$sig - if [ $do_echo -eq 1 ]; then echo $cmd; fi - if [ $do_echo_on_chain -eq 1 ]; then - echo $cmd - echo "" - else - if [ $do_run -eq 1 ]; then eval $cmd; fi - fi let i++ done i=0 tfuelamt=0 +caccum=0 let holdcnt=carolsigs-1 while [ $i -lt $carolsigs ]; do #echo "i:"$i @@ -487,25 +428,27 @@ while [ $i -lt $carolsigs ]; do else tfuelamt=$tfuel fi + + #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig + cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --pw=qwertyuiop --on_chain --src_sig='$sig + if [ $accumulate -eq 1 ]; then if [ $i -lt $holdcnt ]; then echo "Hold::: Carol["$payseq"]" + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_echo_on_chain -eq 1 ]; then echo $cmd; echo ""; fi else echo "Submit: Carol["$payseq"]" - fi + let caccum++ + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_echo_on_chain -eq 1 ]; then echo $cmd; echo ""; else if [ $do_run -eq 1 ]; then eval $cmd; fi fi + fi else echo "Carol["$payseq"]" + if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_echo_on_chain -eq 1 ]; then echo $cmd; echo ""; else if [ $do_run -eq 1 ]; then eval $cmd; fi fi fi - #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig - cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --pw=qwertyuiop --on_chain --src_sig='$sig - if [ $do_echo -eq 1 ]; then echo $cmd; fi - if [ $do_echo_on_chain -eq 1 ]; then - echo $cmd - echo "" - else - if [ $do_run -eq 1 ]; then eval $cmd; fi - fi let i++ done @@ -513,18 +456,29 @@ echo "" echo "End on-chain service-payment transactions." echo "" -end=`date +%s` -let deltatime=end-start +onend=`date +%s` +let deltatime=onend-onstart let hours=deltatime/3600 let minutes=(deltatime/60)%60 let seconds=deltatime%60 -printf "On-Chain Time spent: %d:%02d:%02d\n" $hours $minutes $seconds +cmd='secspertx=$(echo "scale=3; ('$deltatime' / ('$baccum' + '$caccum'))/1" | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +printf "On-Chain Time spent: %d:%02d:%02d (%2.5f sec/tx)\n" $hours $minutes $seconds $secspertx +let deltatime=onend-offstart +let hours=deltatime/3600 +let minutes=(deltatime/60)%60 +let seconds=deltatime%60 +cmd='secspertx=$(echo "scale=3; ('$deltatime' / ('$baccum' + '$caccum' + '$bobsigs' + '$carolsigs'))/1" | bc -q 2>/dev/null)' +if [ $do_echo -eq 1 ]; then echo $cmd; fi +if [ $do_run -eq 1 ]; then eval $cmd; fi +printf "Total TX Time spent: %d:%02d:%02d (%2.5f sec/tx)\n" $hours $minutes $seconds $secspertx aab=$(thetacli query account --address=$Alice | jq .coins.tfuelwei | tr -d '"') bab=$(thetacli query account --address=$Bob | jq .coins.tfuelwei | tr -d '"') -cab=$(thetacli query account --address=$Carol | jq .coins.tfuelwei | tr -d '"') +cax=$(thetacli query account --address=$Carol | jq .coins.tfuelwei | tr -d '"') echo "" echo "Alice initial balance: "$(un_wei $aib) @@ -534,6 +488,6 @@ echo "Bob initial balance : "$(un_wei $bib) echo "Bob final balance : "$(un_wei $bab) echo "" echo "Carol initial balance: "$(un_wei $cib) -echo "Carol final balance : "$(un_wei $cab) +echo "Carol final balance : "$(un_wei $cax) echo "" echo "Finished Batch Test." \ No newline at end of file From 707c6036315f9c83dd43767618ec047b3cb383ab Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Mon, 14 Jun 2021 14:00:44 -0400 Subject: [PATCH 09/20] refactor pwFlag to passwordFlag --- cmd/thetacli/cmd/tx/.reserve_fund.go.swp | Bin 16384 -> 0 bytes cmd/thetacli/cmd/tx/deposit_stake.go | 1 - cmd/thetacli/cmd/tx/main.go | 1 - cmd/thetacli/cmd/tx/release_fund.go | 1 - cmd/thetacli/cmd/tx/reserve_fund.go | 1 - cmd/thetacli/cmd/tx/send.go | 1 - cmd/thetacli/cmd/tx/service_payment.go | 1 - cmd/thetacli/cmd/tx/smart_contract.go | 1 - cmd/thetacli/cmd/tx/split_rule.go | 1 - cmd/thetacli/cmd/tx/withdraw_stake.go | 1 - cmd/thetacli/test/batch.sh | 10 +++++----- 11 files changed, 5 insertions(+), 14 deletions(-) delete mode 100644 cmd/thetacli/cmd/tx/.reserve_fund.go.swp diff --git a/cmd/thetacli/cmd/tx/.reserve_fund.go.swp b/cmd/thetacli/cmd/tx/.reserve_fund.go.swp deleted file mode 100644 index 38ad56e98d383c49559ab59b248393f3599d08bb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeHNOKc=Z87`8LWp{&Z;@Gi!WP0()e)^t~oJMQW3 z?T0V`v3p>{=cfL{^~~Q()R~8wwCaR^e@iNs6 zyy~UOqZcccg@+$}Xlzi!ClZ0hrWF>$bs35g&v!#tckK~d8cpdJ^_CIW=(ZK#w2QtB zq`xWG%*ZhcO?QxntS)09W8h#0?q=0WxkUB%X{Y&z?_E8(X;zalkTH-kkTH-kkTH-k zkTH-kkTLLo$3W=a#%`ilwN&bIe*Z=pD>*GoJ^?oc z_yTYlcmVhaa16Kucj@A3E){c=xKlhp8!q)CxLr_JApTD zXY6OdQ^1!22N(mY!0o`F;M+HVZvo!~t^l6_P6EpBNnGY`uv{(*EjuX8`o8PuwK-wo z!wep}+!KBvx%v>p=lCMSbDcm=@iUuO9Br6O-ydQ*%cLLtbd5Wf&39PNbp4hHLusfM ze5%GD4_v2k0kYPGJ?|LO3G)yZ+2JtPAV=f4G>H0lTS9i#$nL^}GW=}gajB<@p)9t5 z%scCQdSS+Qg`tZeToPL=zHkDehnDLsDLZ#y*&gGT>H8F-C5(Ird_kM*cgP{Fvs4mO z)Vb{;YLCP&@r~3P9(HZ%$cCnUi2rnaaWQ(XVi=RvhEb}FSITBXm?cp)$0wyZ(Ws7A z&IzHH%M&`Q#TVk>Q}M+gnw>r$_Z0TV?yGTplmm|y>cY13n)-m}AhO`g0aQ-=&0uGx zJ+mFkV2TG;6Qr%QZ;;=)v=L{B9rDW2^-c%dj()4k5x;_-pR+|1CLEc?+@?@tgWr$7 z>xHGo`cg7bIs|u{&`2PPdRyg+^s!TCu>8mA?sGQF#rkL*DElwUEf`lZO%b7n<;i*U_{?13fpxJ4PW=|mdp%3{~i6gi24Xat0M-ULHtB8iN(R^u$+RaJ4E@H>j5hekKcwax&^c&a1wywLd zAlVxz^UkKQEh9E=s;6tb6$K%0Nbb3T6d#J?=NO+!f42s7N-`p}_Al{UGZ5Y4R=o3y;_Bth*kotr{+vUds zH5k)((z3i3Vc>x0C}uv8*Ho}jclNjsgW)LtQ%>9M!CW#@5Dh)U1}gyynl2$L?RhFl zm>#&o=<=ER&D|gukyAK+c1T{N1qm57-EyON89_l)??m~$qg<*8*e8U#Z`gQgLtmHn ztE7@c>7;q(sM@65r3|BKVE-`O;;yiqAx*3{lIdf?)i-*lk7T}z*CP9@$>PU``y8g0 zZD2O8TXk%biBECkR-|?q3&0@Qa(yE<0^I1_aC=5-y=BlN{C?eS_@YpETP;ES3B2n& zkxHYDVOT6h@r1QU1R`>_En1$9AikH+~&woLm`D< ztui}Ntxk?j%${q^j8BYB%hB?rK5CS!<%vmirZiEm>!a0%Xi$5&tTtIHk-SdC)XJ4o z6(txpwK4opr_)-wRI1=U9ky$h5!4Jzt_jD5jsBV;wujfHZM#=t|MI%)hctO=2|JvW zaT?*m;jU@MJ>V@%_gznHx3Hwr@Z2h`r|Hs?zM?Q$P^7aVIL0J$wvXW*RxIXn|9e!y zY@WKBekYx#u|(bUrAH-B7;yA0t&OSFOqA+wfq!WLEUWDjf&+loHe6_Bo{r78&!O{O|yP5}gJr#Inxmr|ovR* zHEgWbi+I~oGqV-aKecGW;!O3vuK-Ihjae-Zk;(Inc|zY1c*TTmM*IH-?0J6+(EdL? z-+vi<`X2%}fg8YezyU^pH?g1p1~3l%3VZnm@D}#(PXj~1FR(Yi3|s`}fH$!Ze-U^A zcnVkp#)0F&?-Jd=A^q8vF_1BkF_1BkF_1BkF_1BE%M4(X)xV;qtosIS-jlSIkHl!l!qV*#RK}(*;pJ((*Ard-ATS`hk)odZ<#I4Vg#LMBZG!<>AxoMb4u6SW%1VY#LX;+~VO0kV4t zqe&wP05yL=G#Q;_BWaW(b%319{&UMd?(a#hLry%N5}|dOjxlUW#z%Z`>WXtF MP{*~MbJ-#GFC%{>$^ZZW diff --git a/cmd/thetacli/cmd/tx/deposit_stake.go b/cmd/thetacli/cmd/tx/deposit_stake.go index 2fe9694f..6ad45e20 100644 --- a/cmd/thetacli/cmd/tx/deposit_stake.go +++ b/cmd/thetacli/cmd/tx/deposit_stake.go @@ -185,7 +185,6 @@ func doDepositStakeCmd(cmd *cobra.Command, args []string) { } func init() { - depositStakeCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") depositStakeCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") depositStakeCmd.Flags().StringVar(&sourceFlag, "source", "", "Source of the stake") depositStakeCmd.Flags().StringVar(&holderFlag, "holder", "", "Holder of the stake") diff --git a/cmd/thetacli/cmd/tx/main.go b/cmd/thetacli/cmd/tx/main.go index 78433d5e..e757442a 100644 --- a/cmd/thetacli/cmd/tx/main.go +++ b/cmd/thetacli/cmd/tx/main.go @@ -37,7 +37,6 @@ var ( onChainFlag bool sourceSignatureFlag string dryRunFlag bool - pwFlag string beneficiaryFlag string splitBasisPointFlag uint64 passwordFlag string diff --git a/cmd/thetacli/cmd/tx/release_fund.go b/cmd/thetacli/cmd/tx/release_fund.go index 9c5917dd..543b3f7e 100644 --- a/cmd/thetacli/cmd/tx/release_fund.go +++ b/cmd/thetacli/cmd/tx/release_fund.go @@ -79,7 +79,6 @@ func doReleaseFundCmd(cmd *cobra.Command, args []string) { } func init() { - releaseFundCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") releaseFundCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") releaseFundCmd.Flags().StringVar(&fromFlag, "from", "", "Reserve owner's address") releaseFundCmd.Flags().Uint64Var(&seqFlag, "seq", 0, "Sequence number of the transaction") diff --git a/cmd/thetacli/cmd/tx/reserve_fund.go b/cmd/thetacli/cmd/tx/reserve_fund.go index 1bb0d924..822b2da0 100644 --- a/cmd/thetacli/cmd/tx/reserve_fund.go +++ b/cmd/thetacli/cmd/tx/reserve_fund.go @@ -117,7 +117,6 @@ func doReserveFundCmd(cmd *cobra.Command, args []string) { } func init() { - reserveFundCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") reserveFundCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") reserveFundCmd.Flags().StringVar(&fromFlag, "from", "", "Address to send from") reserveFundCmd.Flags().Uint64Var(&seqFlag, "seq", 0, "Sequence number of the transaction") diff --git a/cmd/thetacli/cmd/tx/send.go b/cmd/thetacli/cmd/tx/send.go index cf5c732e..574174a2 100644 --- a/cmd/thetacli/cmd/tx/send.go +++ b/cmd/thetacli/cmd/tx/send.go @@ -128,7 +128,6 @@ func doSendCmd(cmd *cobra.Command, args []string) { } func init() { - sendCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") sendCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") sendCmd.Flags().StringVar(&fromFlag, "from", "", "Address to send from") sendCmd.Flags().StringVar(&toFlag, "to", "", "Address to send to") diff --git a/cmd/thetacli/cmd/tx/service_payment.go b/cmd/thetacli/cmd/tx/service_payment.go index fc486ca9..313e9118 100644 --- a/cmd/thetacli/cmd/tx/service_payment.go +++ b/cmd/thetacli/cmd/tx/service_payment.go @@ -198,7 +198,6 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { } func init() { - servicePaymentCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") servicePaymentCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") servicePaymentCmd.Flags().StringVar(&fromFlag, "from", "", "Address to send from") servicePaymentCmd.Flags().StringVar(&toFlag, "to", "", "Address to send to") diff --git a/cmd/thetacli/cmd/tx/smart_contract.go b/cmd/thetacli/cmd/tx/smart_contract.go index 5465f854..7664ef66 100644 --- a/cmd/thetacli/cmd/tx/smart_contract.go +++ b/cmd/thetacli/cmd/tx/smart_contract.go @@ -120,7 +120,6 @@ func doSmartContractCmd(cmd *cobra.Command, args []string) { } func init() { - smartContractCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") smartContractCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") smartContractCmd.Flags().StringVar(&fromFlag, "from", "", "The caller address") smartContractCmd.Flags().StringVar(&toFlag, "to", "", "The smart contract address") diff --git a/cmd/thetacli/cmd/tx/split_rule.go b/cmd/thetacli/cmd/tx/split_rule.go index d9fe796c..34c0af02 100644 --- a/cmd/thetacli/cmd/tx/split_rule.go +++ b/cmd/thetacli/cmd/tx/split_rule.go @@ -111,7 +111,6 @@ func doSplitRuleCmd(cmd *cobra.Command, args []string) { } func init() { - splitRuleCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") splitRuleCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") splitRuleCmd.Flags().StringVar(&fromFlag, "from", "", "Initiator's address") splitRuleCmd.Flags().Uint64Var(&seqFlag, "seq", 0, "Sequence number of the transaction") diff --git a/cmd/thetacli/cmd/tx/withdraw_stake.go b/cmd/thetacli/cmd/tx/withdraw_stake.go index 02ab3d0d..9dbd71e2 100644 --- a/cmd/thetacli/cmd/tx/withdraw_stake.go +++ b/cmd/thetacli/cmd/tx/withdraw_stake.go @@ -85,7 +85,6 @@ func doWithdrawStakeCmd(cmd *cobra.Command, args []string) { } func init() { - withdrawStakeCmd.Flags().StringVar(&pwFlag, "pw", "", "Password") withdrawStakeCmd.Flags().StringVar(&chainIDFlag, "chain", "", "Chain ID") withdrawStakeCmd.Flags().StringVar(&sourceFlag, "source", "", "Source of the stake") withdrawStakeCmd.Flags().StringVar(&holderFlag, "holder", "", "Holder of the stake") diff --git a/cmd/thetacli/test/batch.sh b/cmd/thetacli/test/batch.sh index 05f28077..9a8dd40b 100755 --- a/cmd/thetacli/test/batch.sh +++ b/cmd/thetacli/test/batch.sh @@ -252,7 +252,7 @@ if [ ${#arf} == 2 ]; then if [ $do_run -eq 1 ]; then eval $cmd; fi echo "Using: "$rfdurationblocks" blocks = "$rfdurationsecs"secs" fi - cmd='thetacli tx reserve --chain="privatenet" --async --from='$Alice' --fund='$rfund' --collateral='$rcoll' --duration='$rfdurationblocks' --resource_ids='$rid' --seq='$ans' --pw=qwertyuiop' + cmd='thetacli tx reserve --chain="privatenet" --async --from='$Alice' --fund='$rfund' --collateral='$rcoll' --duration='$rfdurationblocks' --resource_ids='$rid' --seq='$ans' --password=qwertyuiop' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi echo "Alice end create reserve. Wait 15 seconds and rereun." @@ -319,7 +319,7 @@ while [ $i -lt $bobsigs ]; do fi echo "Bob:"$payseq" = "$tfuelamt #cmd='sigout=$(./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$i' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' | tail -n +6 | jq .source.signature | tr -d '"'"'"'"'"')' - cmd='sigout=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --pw=qwertyuiop | jq .source.signature | tr -d '"'"'"'"'"')' + cmd='sigout=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --password=qwertyuiop | jq .source.signature | tr -d '"'"'"'"'"')' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi sigs+=($sigout) @@ -341,7 +341,7 @@ while [ $i -lt $carolsigs ]; do fi echo "Carol:"$payseq" = "$tfuelamt #cmd='sigout=$(./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$i' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' | tail -n +6 | jq .source.signature | tr -d '"'"'"'"'"')' - cmd='sigout=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --pw=qwertyuiop | jq .source.signature | tr -d '"'"'"'"'"')' + cmd='sigout=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --password=qwertyuiop | jq .source.signature | tr -d '"'"'"'"'"')' if [ $do_echo -eq 1 ]; then echo $cmd; fi if [ $do_run -eq 1 ]; then eval $cmd; fi sigs+=($sigout) @@ -391,7 +391,7 @@ while [ $i -lt $bobsigs ]; do fi #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig - cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --pw=qwertyuiop --on_chain --src_sig='$sig + cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --password=qwertyuiop --on_chain --src_sig='$sig if [ $accumulate -eq 1 ]; then if [ $i -lt $holdcnt ]; then @@ -430,7 +430,7 @@ while [ $i -lt $carolsigs ]; do fi #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig - cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --pw=qwertyuiop --on_chain --src_sig='$sig + cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --password=qwertyuiop --on_chain --src_sig='$sig if [ $accumulate -eq 1 ]; then if [ $i -lt $holdcnt ]; then From b33fdb79506d906fea62f1030db624278d17f5cc Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Mon, 14 Jun 2021 14:06:19 -0400 Subject: [PATCH 10/20] refactor tweek --- cmd/thetacli/cmd/tx/reserve_fund.go | 2 +- cmd/thetacli/cmd/tx/service_payment.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/thetacli/cmd/tx/reserve_fund.go b/cmd/thetacli/cmd/tx/reserve_fund.go index 822b2da0..c78d4f1b 100644 --- a/cmd/thetacli/cmd/tx/reserve_fund.go +++ b/cmd/thetacli/cmd/tx/reserve_fund.go @@ -12,7 +12,7 @@ import ( "github.com/thetatoken/theta/ledger/types" "github.com/thetatoken/theta/rpc" - "github.com/ybbus/jsonrpc" +// "github.com/ybbus/jsonrpc" rpcc "github.com/ybbus/jsonrpc" ) diff --git a/cmd/thetacli/cmd/tx/service_payment.go b/cmd/thetacli/cmd/tx/service_payment.go index 313e9118..72938501 100644 --- a/cmd/thetacli/cmd/tx/service_payment.go +++ b/cmd/thetacli/cmd/tx/service_payment.go @@ -55,13 +55,13 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { if onChainFlag { // if 1 == 1 { - twallet, toAddress, err = walletUnlockWithPath(cmd, toFlag, pathFlag) + twallet, toAddress, err = walletUnlockWithPath(cmd, toFlag, pathFlag, passwordFlag) if err != nil || twallet == nil { return } defer twallet.Lock(toAddress) } else { - swallet, fromAddress, err = walletUnlockWithPath(cmd, fromFlag, pathFlag) + swallet, fromAddress, err = walletUnlockWithPath(cmd, fromFlag, pathFlag, passwordFlag) if err != nil || swallet == nil { return } From 31e95427f1ebe5e128d2f0f9a0609991e3932d15 Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Mon, 14 Jun 2021 14:32:01 -0400 Subject: [PATCH 11/20] refactor testing ok --- cmd/thetacli/cmd/tx/reserve_fund.go | 4 +++- cmd/thetacli/cmd/tx/send.go | 5 ++++- cmd/thetacli/cmd/tx/service_payment.go | 5 ++++- cmd/thetacli/cmd/tx/smart_contract.go | 4 +++- cmd/thetacli/test/batch.sh | 14 +++++++------- cmd/thetacli/test/defaultpw | 1 - cmd/thetacli/test/reserve.sh | 15 --------------- cmd/thetacli/test/send.sh | 15 --------------- cmd/thetacli/test/sp.sh | 17 ----------------- 9 files changed, 21 insertions(+), 59 deletions(-) delete mode 100644 cmd/thetacli/test/defaultpw delete mode 100755 cmd/thetacli/test/reserve.sh delete mode 100755 cmd/thetacli/test/send.sh delete mode 100755 cmd/thetacli/test/sp.sh diff --git a/cmd/thetacli/cmd/tx/reserve_fund.go b/cmd/thetacli/cmd/tx/reserve_fund.go index c78d4f1b..9a946378 100644 --- a/cmd/thetacli/cmd/tx/reserve_fund.go +++ b/cmd/thetacli/cmd/tx/reserve_fund.go @@ -111,7 +111,9 @@ func doReserveFundCmd(cmd *cobra.Command, args []string) { if err != nil { utils.Error("Failed to parse server response: %v\n", err) } - fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) + //fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) + // Verbose output makes parsing json difficult + fmt.Printf("%s\n", formatted) //fmt.Printf("Successfully broadcasted transaction.\n") } diff --git a/cmd/thetacli/cmd/tx/send.go b/cmd/thetacli/cmd/tx/send.go index 574174a2..848566d1 100644 --- a/cmd/thetacli/cmd/tx/send.go +++ b/cmd/thetacli/cmd/tx/send.go @@ -124,7 +124,10 @@ func doSendCmd(cmd *cobra.Command, args []string) { if err != nil { utils.Error("Failed to parse server response: %v\n", err) } - fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) + // Verbose output makes parsing json difficult + //fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) + // Verbose output makes parsing json difficult + fmt.Printf("%s\n", formatted) } func init() { diff --git a/cmd/thetacli/cmd/tx/service_payment.go b/cmd/thetacli/cmd/tx/service_payment.go index 72938501..09abd976 100644 --- a/cmd/thetacli/cmd/tx/service_payment.go +++ b/cmd/thetacli/cmd/tx/service_payment.go @@ -184,7 +184,9 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { if err != nil { utils.Error("Failed to parse server response: %v\n", err) } - fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) + //fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) + // Verbose output makes parsing json difficult + fmt.Printf("%s\n", formatted) } } else { formatted, err := json.MarshalIndent(servicePaymentTx, "", " ") @@ -211,6 +213,7 @@ func init() { servicePaymentCmd.Flags().StringVar(&sourceSignatureFlag, "src_sig", "unsigned", "Source Signature from prior Off-Chain transaction") servicePaymentCmd.Flags().BoolVar(&onChainFlag, "on_chain", false, "Process transaction On-Chain else return json of what would have been sent") servicePaymentCmd.Flags().BoolVar(&asyncFlag, "async", false, "Block until tx has been included in the blockchain") + servicePaymentCmd.Flags().StringVar(&passwordFlag, "password", "", "password to unlock the wallet") servicePaymentCmd.Flags().BoolVar(&dryRunFlag, "dry_run", false, "Dry Run(don't execute) the On-Chain transaction") servicePaymentCmd.MarkFlagRequired("chain") diff --git a/cmd/thetacli/cmd/tx/smart_contract.go b/cmd/thetacli/cmd/tx/smart_contract.go index 7664ef66..6fc4f171 100644 --- a/cmd/thetacli/cmd/tx/smart_contract.go +++ b/cmd/thetacli/cmd/tx/smart_contract.go @@ -116,7 +116,9 @@ func doSmartContractCmd(cmd *cobra.Command, args []string) { if err != nil { utils.Error("Failed to parse server response: %v\n", err) } - fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) + //fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) + // Verbose output makes parsing json difficult + fmt.Printf("%s\n", formatted) } func init() { diff --git a/cmd/thetacli/test/batch.sh b/cmd/thetacli/test/batch.sh index 9a8dd40b..12c1d484 100755 --- a/cmd/thetacli/test/batch.sh +++ b/cmd/thetacli/test/batch.sh @@ -25,11 +25,11 @@ rfund=100 rcoll=101 #tfuel=0.1 -tfuel=2 +tfuel=0.3 # total 10 items -bobsigs=10 -carolsigs=10 +bobsigs=1 +carolsigs=0 tfuelfee=0.3 tfuelperc=0.0 @@ -391,7 +391,7 @@ while [ $i -lt $bobsigs ]; do fi #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig - cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --password=qwertyuiop --on_chain --src_sig='$sig + cmd='sphash=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --password=qwertyuiop --on_chain --src_sig='$sig' | jq .hash)' if [ $accumulate -eq 1 ]; then if [ $i -lt $holdcnt ]; then @@ -402,7 +402,7 @@ while [ $i -lt $bobsigs ]; do echo "Submit: Bob["$payseq"]" let baccum++ if [ $do_echo -eq 1 ]; then echo $cmd; fi - if [ $do_echo_on_chain -eq 1 ]; then echo $cmd; echo ""; else if [ $do_run -eq 1 ]; then eval $cmd; fi fi + if [ $do_echo_on_chain -eq 1 ]; then echo $cmd; echo ""; else if [ $do_run -eq 1 ]; then eval $cmd; echo $sphash; fi fi fi else echo "Bob["$payseq"]" @@ -430,7 +430,7 @@ while [ $i -lt $carolsigs ]; do fi #cmd='./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$ans' --resource_id='$rid' --tfuel='$tfuel' --on_chain --src_sig='$sig - cmd='thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --password=qwertyuiop --on_chain --src_sig='$sig + cmd='sphash=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --password=qwertyuiop --on_chain --src_sig='$sig' | jq .hash)' if [ $accumulate -eq 1 ]; then if [ $i -lt $holdcnt ]; then @@ -441,7 +441,7 @@ while [ $i -lt $carolsigs ]; do echo "Submit: Carol["$payseq"]" let caccum++ if [ $do_echo -eq 1 ]; then echo $cmd; fi - if [ $do_echo_on_chain -eq 1 ]; then echo $cmd; echo ""; else if [ $do_run -eq 1 ]; then eval $cmd; fi fi + if [ $do_echo_on_chain -eq 1 ]; then echo $cmd; echo ""; else if [ $do_run -eq 1 ]; then eval $cmd; echo $sphash; fi fi fi else echo "Carol["$payseq"]" diff --git a/cmd/thetacli/test/defaultpw b/cmd/thetacli/test/defaultpw deleted file mode 100644 index f04fd8d8..00000000 --- a/cmd/thetacli/test/defaultpw +++ /dev/null @@ -1 +0,0 @@ -qwertyuiop \ No newline at end of file diff --git a/cmd/thetacli/test/reserve.sh b/cmd/thetacli/test/reserve.sh deleted file mode 100755 index 654aa37b..00000000 --- a/cmd/thetacli/test/reserve.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/expect -f -set timeout -1 -set arg1 [lindex $argv 0] -set arg2 [lindex $argv 1] -set arg3 [lindex $argv 2] -set arg4 [lindex $argv 3] -set arg5 [lindex $argv 4] -set arg6 [lindex $argv 5] -spawn thetacli tx reserve --async --chain="privatenet" $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 -set code [open "./defaultpw" r] -set pass [read $code] -expect { - password: {send "$pass\n" ; exp_continue} - eof exit -} diff --git a/cmd/thetacli/test/send.sh b/cmd/thetacli/test/send.sh deleted file mode 100755 index c28d3be1..00000000 --- a/cmd/thetacli/test/send.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/expect -f -set timeout -1 -set arg1 [lindex $argv 0] -set arg2 [lindex $argv 1] -set arg3 [lindex $argv 2] -set arg4 [lindex $argv 3] -set arg5 [lindex $argv 4] -set arg6 [lindex $argv 5] -spawn thetacli tx send --chain="privatenet" $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 -set code [open "./defaultpw" r] -set pass [read $code] -expect { - password: {send "$pass\r" ; exp_continue} - eof exit -} diff --git a/cmd/thetacli/test/sp.sh b/cmd/thetacli/test/sp.sh deleted file mode 100755 index b3de35e2..00000000 --- a/cmd/thetacli/test/sp.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/expect -f -set timeout -1 -set arg1 [lindex $argv 0] -set arg2 [lindex $argv 1] -set arg3 [lindex $argv 2] -set arg4 [lindex $argv 3] -set arg5 [lindex $argv 4] -set arg6 [lindex $argv 5] -set arg7 [lindex $argv 6] -set arg8 [lindex $argv 7] -spawn thetacli tx service_payment --chain="privatenet" $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 $arg7 $arg8 -set code [open "./defaultpw" r] -set pass [read $code] -expect { - password: {send "$pass\r" ; exp_continue} - eof exit -} From 3b39fa601ce500f0cbc742bcc9d41f7cecb34bcf Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Mon, 19 Jul 2021 12:12:31 -0400 Subject: [PATCH 12/20] output some values to help debug javascript libs --- cmd/thetacli/cmd/tx/reserve_fund.go | 4 ++++ cmd/thetacli/cmd/tx/service_payment.go | 2 ++ ledger/types/tx.go | 15 +++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/cmd/thetacli/cmd/tx/reserve_fund.go b/cmd/thetacli/cmd/tx/reserve_fund.go index 9a946378..6dd203dd 100644 --- a/cmd/thetacli/cmd/tx/reserve_fund.go +++ b/cmd/thetacli/cmd/tx/reserve_fund.go @@ -82,6 +82,10 @@ func doReserveFundCmd(cmd *cobra.Command, args []string) { } reserveFundTx.SetSignature(fromAddress, sig) + // reqformatted, err := json.MarshalIndent(reserveFundTx, "", " ") + // fmt.Printf("ReserveFundRequest:\n%s\n", reqformatted) + + raw, err := types.TxToBytes(reserveFundTx) if err != nil { utils.Error("Failed to encode transaction: %v\n", err) diff --git a/cmd/thetacli/cmd/tx/service_payment.go b/cmd/thetacli/cmd/tx/service_payment.go index 09abd976..d6b362eb 100644 --- a/cmd/thetacli/cmd/tx/service_payment.go +++ b/cmd/thetacli/cmd/tx/service_payment.go @@ -114,6 +114,7 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { ResourceID: resourceIDFlag, } + // Set the Source Signature if onChainFlag { //ssig, err := crypto.UnmarshalJSON([]byte(sourceSignatureFlag)) ssig, err := crypto.SignatureFromBytes(common.FromHex(sourceSignatureFlag)) @@ -129,6 +130,7 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { servicePaymentTx.SetSourceSignature(ssig) } + // Set the Target Signature if onChainFlag { tsig, err := twallet.Sign(toAddress, servicePaymentTx.TargetSignBytes(chainIDFlag)) if err != nil { diff --git a/ledger/types/tx.go b/ledger/types/tx.go index 382b6ffa..18964f3e 100644 --- a/ledger/types/tx.go +++ b/ledger/types/tx.go @@ -587,6 +587,12 @@ func (_ *ServicePaymentTx) AssertIsTx() {} func (tx *ServicePaymentTx) SourceSignBytes(chainID string) []byte { signBytes := encodeToBytes(chainID) + //formatted, err := json.MarshalIndent(result, "", " ") + //if err != nil { + // utils.Error("Failed : %v\n", err) + //} + fmt.Printf("signBytes: %s\n", hex.EncodeToString(signBytes)) + source := tx.Source target := tx.Target fee := tx.Fee @@ -595,8 +601,16 @@ func (tx *ServicePaymentTx) SourceSignBytes(chainID string) []byte { tx.Target = TxInput{Address: target.Address} tx.Fee = NewCoins(0, 0) + formatted, err := json.MarshalIndent(tx, "", " ") + if err != nil { + fmt.Printf("Failed : %v\n", err) + } + fmt.Printf("tx: %s\n", formatted) + txBytes, _ := TxToBytes(tx) + fmt.Printf("txBytes: %s\n", hex.EncodeToString(txBytes)) signBytes = append(signBytes, txBytes...) + fmt.Printf("append signBytes: %s\n", hex.EncodeToString(signBytes)) tx.Source = source tx.Target = target @@ -604,6 +618,7 @@ func (tx *ServicePaymentTx) SourceSignBytes(chainID string) []byte { signBytes = addPrefixForSignBytes(signBytes) + fmt.Printf("addPrefixForSignBytes: %s\n", hex.EncodeToString(signBytes)) return signBytes } From 430e2871beb7455a447eca7c13d3a165d0ac16f8 Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Fri, 23 Jul 2021 13:30:17 -0400 Subject: [PATCH 13/20] version --- version/{.gitignore => gitignore} | 0 version/version_generated.go | 6 ++++++ 2 files changed, 6 insertions(+) rename version/{.gitignore => gitignore} (100%) create mode 100644 version/version_generated.go diff --git a/version/.gitignore b/version/gitignore similarity index 100% rename from version/.gitignore rename to version/gitignore diff --git a/version/version_generated.go b/version/version_generated.go new file mode 100644 index 00000000..92a300d1 --- /dev/null +++ b/version/version_generated.go @@ -0,0 +1,6 @@ +package version +const ( + Timestamp = "Wed Jul 21 20:40:34 UTC 2021" + Version = "3.1.0" + GitHash = "3b39fa601ce500f0cbc742bcc9d41f7cecb34bcf" +) From 581899d5717521e4d131a3d0a8c5b4fed5c8034a Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Fri, 23 Jul 2021 13:35:00 -0400 Subject: [PATCH 14/20] version --- version/version_generated.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/version_generated.go b/version/version_generated.go index 92a300d1..faa43fb8 100644 --- a/version/version_generated.go +++ b/version/version_generated.go @@ -1,4 +1,4 @@ -package version +package github.com/thetatoken/theta/version const ( Timestamp = "Wed Jul 21 20:40:34 UTC 2021" Version = "3.1.0" From 42ef5770b6367570ba5292e40c6f4c8111ace89d Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Fri, 23 Jul 2021 13:37:30 -0400 Subject: [PATCH 15/20] ver again --- version/version_generated.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/version_generated.go b/version/version_generated.go index faa43fb8..92a300d1 100644 --- a/version/version_generated.go +++ b/version/version_generated.go @@ -1,4 +1,4 @@ -package github.com/thetatoken/theta/version +package version const ( Timestamp = "Wed Jul 21 20:40:34 UTC 2021" Version = "3.1.0" From 8ff8109df2f935ccf8552599b3268dfc4107f0e8 Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Fri, 23 Jul 2021 13:39:28 -0400 Subject: [PATCH 16/20] modsum --- go.mod | 15 ----------- go.sum | 79 +++++++++------------------------------------------------- 2 files changed, 12 insertions(+), 82 deletions(-) diff --git a/go.mod b/go.mod index 2a321cbb..cab516b2 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ require ( github.com/bgentry/speakeasy v0.1.0 github.com/davecgh/go-spew v1.1.1 github.com/dgraph-io/badger v1.6.0-rc1 - github.com/fd/go-nat v1.0.0 github.com/golang/protobuf v1.3.1 github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db github.com/gorilla/context v1.1.1 // indirect @@ -13,9 +12,7 @@ require ( github.com/hashicorp/golang-lru v0.5.1 github.com/herumi/bls-eth-go-binary v0.0.0-20200107021104-147ed25f233e github.com/huin/goupnp v1.0.0 - github.com/influxdata/influxdb v1.7.8 // indirect github.com/ipfs/go-datastore v0.0.5 - github.com/ipfs/go-ipfs-addr v0.0.1 github.com/jackpal/gateway v1.0.5 github.com/jackpal/go-nat-pmp v1.0.1 github.com/karalabe/hid v0.0.0-20180420081245-2b4488a37358 @@ -27,25 +24,15 @@ require ( github.com/libp2p/go-libp2p-kad-dht v0.2.0 github.com/libp2p/go-libp2p-peerstore v0.1.3 github.com/libp2p/go-libp2p-pubsub v0.1.1 - github.com/libp2p/go-libp2p-swarm v0.2.0 - github.com/libp2p/go-libp2p-transport v0.1.0 - github.com/libp2p/go-nat v0.0.3 - github.com/libp2p/go-stream-muxer v0.1.0 github.com/mattn/go-isatty v0.0.12 github.com/mitchellh/go-homedir v1.1.0 github.com/mongodb/mongo-go-driver v0.0.17 github.com/multiformats/go-multiaddr v0.0.4 github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709 - github.com/phoreproject/bls v0.0.0-20191016230924-b2e57acce2ed - github.com/pion/datachannel v1.4.13 - github.com/pion/webrtc/v2 v2.1.12 github.com/pkg/errors v0.8.1 - github.com/pkg/profile v1.4.0 - github.com/prysmaticlabs/prysm v0.0.0-20191018160938-a05dca18c7f7 github.com/russross/blackfriday v2.0.0+incompatible // indirect github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect github.com/sirupsen/logrus v1.4.2 - github.com/smira/go-statsd v1.3.1 github.com/spf13/cobra v0.0.5 github.com/spf13/viper v1.5.0 github.com/stretchr/testify v1.4.0 @@ -53,12 +40,10 @@ require ( github.com/thetatoken/theta/common v0.0.0 github.com/thetatoken/theta/rpc/lib/rpc-codec/jsonrpc2 v0.0.0 github.com/tidwall/pretty v1.0.0 // indirect - github.com/wedeploy/gosocketio v0.0.7-beta github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc // indirect github.com/ybbus/jsonrpc v1.1.1 github.com/yuin/gopher-lua v0.0.0-20180827083657-b942cacc89fe // indirect - go.opencensus.io v0.21.0 golang.org/x/crypto v0.0.0-20191001170739-f9e2070545dc golang.org/x/net v0.0.0-20191021144547-ec77196f6094 golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae diff --git a/go.sum b/go.sum index 3873fca7..24cc005b 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9 h1:HD8gA2tkByhMAwYaFAX9w2l7vxvBQ5NMoxDrkhqhtn4= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Kubuxu/go-os-helper v0.0.1/go.mod h1:N8B+I7vPCT80IcP58r50u4+gEEcsZETFUpAzWW2ep1Y= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -26,9 +27,7 @@ github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVa github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= @@ -52,11 +51,8 @@ github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUn github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/dlespiau/covertool v0.0.0-20180314162135-b0c4c6d0583a/go.mod h1:/eQMcW3eA1bzKx23ZYI2H3tXPdJB5JWYTHzoUPBvQY4= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/fd/go-nat v1.0.0 h1:DPyQ97sxA9ThrWYRPcWUz/z9TnpTIGRYODIQc/dy64M= -github.com/fd/go-nat v1.0.0/go.mod h1:BTBu/CKvMmOMUPkKVef1pngt2WFH/lg7E6yQnulfp6E= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -73,7 +69,6 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= @@ -81,10 +76,11 @@ github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/pprof v0.0.0-20190309163659-77426154d546/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= @@ -102,15 +98,13 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/herumi/bls-eth-go-binary v0.0.0-20200107021104-147ed25f233e h1:IIwtoV/tqnBPfJa9c1wJTv3lu5VAZIs6gnqHbI1Q23k= github.com/herumi/bls-eth-go-binary v0.0.0-20200107021104-147ed25f233e/go.mod h1:WKIQeicfSedn/NDDV6IiaxUcthn5gp3w6RbIG/GOLAg= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huin/goupnp v0.0.0-20180415215157-1395d1447324/go.mod h1:MZ2ZmwcBpvOoJ22IJsc7va19ZwoheaBk43rKg12SKag= github.com/huin/goupnp v1.0.0 h1:wg75sLpL6DZqwHQN6E1Cfk6mtfzS45z8OV+ic+DtHRo= github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/influxdata/influxdb v1.7.8/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= github.com/ipfs/go-cid v0.0.2 h1:tuuKaZPU1M6HcejsO3AcYWW8sZ8MTvyxfc4uqB4eFE8= github.com/ipfs/go-cid v0.0.2/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= @@ -122,7 +116,6 @@ github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46U github.com/ipfs/go-ds-badger v0.0.2/go.mod h1:Y3QpeSFWQf6MopLTiZD+VT6IC1yZqaGmjvRcKeSGij8= github.com/ipfs/go-ds-badger v0.0.5/go.mod h1:g5AuuCGmr7efyzQhLL8MzwqcauPojGPUaHzfGTzuE3s= github.com/ipfs/go-ds-leveldb v0.0.1/go.mod h1:feO8V3kubwsEF22n0YRQCffeb79OOYIykR4L04tMOYc= -github.com/ipfs/go-ipfs-addr v0.0.1/go.mod h1:uKTDljHT3Q3SUWzDLp3aYUi8MrY32fgNgogsIa0npjg= github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= github.com/ipfs/go-ipfs-util v0.0.1 h1:Wz9bL2wB2YBJqggkA4dD7oSmqB4cAnpNbGrlHJulv50= github.com/ipfs/go-ipfs-util v0.0.1/go.mod h1:spsl5z8KUnrve+73pOhSVZND1SIxPW5RyBCNzQxlJBc= @@ -130,12 +123,12 @@ github.com/ipfs/go-log v0.0.1 h1:9XTUN/rW64BCG1YhPK9Hoy3q8nr4gOmHHBpgFdfw6Lc= github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM= github.com/ipfs/go-todocounter v0.0.1 h1:kITWA5ZcQZfrUnDNkRn04Xzh0YFaDFXsoO2A81Eb6Lw= github.com/ipfs/go-todocounter v0.0.1/go.mod h1:l5aErvQc8qKE2r7NDMjmq5UNAvuZy0rC8BHOplkWvZ4= -github.com/jackpal/gateway v1.0.4/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA= github.com/jackpal/gateway v1.0.5 h1:qzXWUJfuMdlLMtt0a3Dgt+xkWQiA5itDEITVJtuSwMc= github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA= github.com/jackpal/go-nat-pmp v1.0.1 h1:i0LektDkO1QlrTm/cSuP+PyBCDnYvjPLGl4LdWEMiaA= github.com/jackpal/go-nat-pmp v1.0.1/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jbenet/go-cienv v0.0.0-20150120210510-1bb1476777ec/go.mod h1:rGaEvXB4uRSZMmzKNLoXvTu1sfx+1kv/DojUlPrSZGs= +github.com/jbenet/go-cienv v0.1.0 h1:Vc/s0QbQtoxX8MwwSLWWh+xNNZvM3Lw7NsTcHrvvhMc= github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= github.com/jbenet/go-temp-err-catcher v0.0.0-20150120210811-aac704a3f4f2 h1:vhC1OXXiT9R2pczegwz6moDvuRpggaroAXhPIseh57A= github.com/jbenet/go-temp-err-catcher v0.0.0-20150120210811-aac704a3f4f2/go.mod h1:8GXXJV31xl8whumTzdZsTt3RnUIiPqzkyf7mxToRCMs= @@ -190,8 +183,6 @@ github.com/libp2p/go-libp2p-core v0.0.4/go.mod h1:jyuCQP356gzfCFtRKyvAbNkyeuxb7O github.com/libp2p/go-libp2p-core v0.0.6/go.mod h1:0d9xmaYAVY5qmbp/fcgxHT3ZJsLjYeYPMJAUKpaCHrE= github.com/libp2p/go-libp2p-core v0.2.0 h1:ycFtuNwtZBAJSxzaHbyv6NjG3Yj5Nmra1csHaQ3zwaw= github.com/libp2p/go-libp2p-core v0.2.0/go.mod h1:X0eyB0Gy93v0DZtSYbEM7RnMChm9Uv3j7yRXjO77xSI= -github.com/libp2p/go-libp2p-core v0.3.0 h1:F7PqduvrztDtFsAa/bcheQ3azmNo+Nq7m8hQY5GiUW8= -github.com/libp2p/go-libp2p-crypto v0.0.1/go.mod h1:yJkNyDmO341d5wwXxDUGO0LykUVT72ImHNUqh5D/dBE= github.com/libp2p/go-libp2p-crypto v0.1.0 h1:k9MFy+o2zGDNGsaoZl0MA3iZ75qXxr9OOoAZF+sD5OQ= github.com/libp2p/go-libp2p-crypto v0.1.0/go.mod h1:sPUokVISZiy+nNuTTH/TY+leRSxnFj/2GLjtOTW90hI= github.com/libp2p/go-libp2p-discovery v0.1.0 h1:j+R6cokKcGbnZLf4kcNwpx6mDEUPF3N6SrqMymQhmvs= @@ -209,7 +200,6 @@ github.com/libp2p/go-libp2p-nat v0.0.4 h1:+KXK324yaY701On8a0aGjTnw8467kW3ExKcqW2 github.com/libp2p/go-libp2p-nat v0.0.4/go.mod h1:N9Js/zVtAXqaeT99cXgTV9e75KpnWCvVOiGzlcHmBbY= github.com/libp2p/go-libp2p-netutil v0.1.0 h1:zscYDNVEcGxyUpMd0JReUZTrpMfia8PmLKcKF72EAMQ= github.com/libp2p/go-libp2p-netutil v0.1.0/go.mod h1:3Qv/aDqtMLTUyQeundkKsA+YCThNdbQD54k3TqjpbFU= -github.com/libp2p/go-libp2p-peer v0.0.1/go.mod h1:nXQvOBbwVqoP+T5Y5nCjeH4sP9IX/J0AMzcDUVruVoo= github.com/libp2p/go-libp2p-peer v0.2.0/go.mod h1:RCffaCvUyW2CJmG2gAWVqwePwW7JMgxjsHm7+J5kjWY= github.com/libp2p/go-libp2p-peerstore v0.1.0/go.mod h1:2CeHkQsr8svp4fZ+Oi9ykN1HBb6u0MOvdJ7YIsmcwtY= github.com/libp2p/go-libp2p-peerstore v0.1.3 h1:wMgajt1uM2tMiqf4M+4qWKVyyFc8SfA+84VV9glZq1M= @@ -226,13 +216,11 @@ github.com/libp2p/go-libp2p-secio v0.2.0/go.mod h1:2JdZepB8J5V9mBp79BmwsaPQhRPNN github.com/libp2p/go-libp2p-swarm v0.1.0/go.mod h1:wQVsCdjsuZoc730CgOvh5ox6K8evllckjebkdiY5ta4= github.com/libp2p/go-libp2p-swarm v0.2.0 h1:gUqj9WYFC9mQ6khEtO5EjfaAtevwBMxsXRARbi6lAiI= github.com/libp2p/go-libp2p-swarm v0.2.0/go.mod h1:x07b4zkMFo2EvgPV2bMTlNmdQc8i+74Jjio7xGvsTgU= -github.com/libp2p/go-libp2p-testing v0.0.1/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= github.com/libp2p/go-libp2p-testing v0.0.2/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= github.com/libp2p/go-libp2p-testing v0.0.3/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= github.com/libp2p/go-libp2p-testing v0.0.4/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= github.com/libp2p/go-libp2p-testing v0.1.0 h1:WaFRj/t3HdMZGNZqnU2pS7pDRBmMeoDx7/HDNpeyT9U= github.com/libp2p/go-libp2p-testing v0.1.0/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0= -github.com/libp2p/go-libp2p-transport v0.1.0/go.mod h1:iL3c2tV3OVldqSwJrds8pmIWf4t/TwiF+eI/mhw/jjQ= github.com/libp2p/go-libp2p-transport-upgrader v0.1.1 h1:PZMS9lhjK9VytzMCW3tWHAXtKXmlURSc3ZdvwEcKCzw= github.com/libp2p/go-libp2p-transport-upgrader v0.1.1/go.mod h1:IEtA6or8JUbsV07qPW4r01GnTenLW4oi3lOPbUMGJJA= github.com/libp2p/go-libp2p-yamux v0.2.0/go.mod h1:Db2gU+XfLpm6E4rG5uGCFX6uXA8MEXOxFcRoXUODaK8= @@ -254,7 +242,6 @@ github.com/libp2p/go-reuseport v0.0.1/go.mod h1:jn6RmB1ufnQwl0Q1f+YxAj8isJgDCQza github.com/libp2p/go-reuseport-transport v0.0.2 h1:WglMwyXyBu61CMkjCCtnmqNqnjib0GIEjMiHTwR/KN4= github.com/libp2p/go-reuseport-transport v0.0.2/go.mod h1:YkbSDrvjUVDL6b8XqriyA20obEtsW9BLkuOUyQAOCbs= github.com/libp2p/go-stream-muxer v0.0.1/go.mod h1:bAo8x7YkSpadMTbtTaxGVHWUQsR/l5MEaHbKaliuT14= -github.com/libp2p/go-stream-muxer v0.1.0/go.mod h1:8JAVsjeRBCWwPoZeH0W1imLOcriqXJyFvB0mR4A04sQ= github.com/libp2p/go-stream-muxer-multistream v0.2.0 h1:714bRJ4Zy9mdhyTLJ+ZKiROmAFwUHpeRidG+q7LTQOg= github.com/libp2p/go-stream-muxer-multistream v0.2.0/go.mod h1:j9eyPol/LLRqT+GPLSxvimPhNph4sfYfMoDPd7HkzIc= github.com/libp2p/go-tcp-transport v0.1.0 h1:IGhowvEqyMFknOar4FWCKSWE0zL36UFKQtiRQD60/8o= @@ -264,13 +251,11 @@ github.com/libp2p/go-ws-transport v0.1.0/go.mod h1:rjw1MG1LU9YDC6gzmwObkPd/Sqwhw github.com/libp2p/go-yamux v1.2.2/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= github.com/libp2p/go-yamux v1.2.3 h1:xX8A36vpXb59frIzWFdEgptLMsOANMFq2K7fPRlunYI= github.com/libp2p/go-yamux v1.2.3/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= -github.com/lucas-clemente/quic-go v0.7.1-0.20190401152353-907071221cf9/go.mod h1:PpMmPfPKO9nKJ/psF49ESTAGQSdfXxlg1otPbEB2nOw= github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/marten-seemann/qtls v0.2.3/go.mod h1:xzjG7avBwGGbdZ8dTGxlBnLArsVKLvwmjgmPuiQEcYk= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= @@ -297,7 +282,6 @@ github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mmcloughlin/avo v0.0.0-20190318053554-7a0eb66183da/go.mod h1:lf5GMZxA5kz8dnCweJuER5Rmbx6dDu6qvw0fO3uYKK8= github.com/mongodb/mongo-go-driver v0.0.17 h1:z59HzYE2ACIsX/xnURjlUGQCSEYXDYp0WiLzd+il8KI= github.com/mongodb/mongo-go-driver v0.0.17/go.mod h1:NK/HWDIIZkaYsnYa0hmtP443T5ELr0KDecmIioVuuyU= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= @@ -328,8 +312,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -337,34 +323,9 @@ github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709 h1:zNBQb37RGLmJybyMcs github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/phoreproject/bls v0.0.0-20191016230924-b2e57acce2ed h1:pX150rn565RorbtQWv2pR0SGd5rr9iHSGCSR26dg5Wk= -github.com/phoreproject/bls v0.0.0-20191016230924-b2e57acce2ed/go.mod h1:7pK0Ldy91shCmI47LLTn3i3rfTQcHiJJvPqGqzvN5nE= -github.com/pion/datachannel v1.4.12/go.mod h1:Ulrx2j4r8c0Za5ltWFv/hZvSpc3ZpvOvcz46tvnt+PY= -github.com/pion/datachannel v1.4.13/go.mod h1:+rBUwEDonA63KXx994DP/ofyyGVAm6AIMvOqQZxjWRU= -github.com/pion/dtls v1.5.3/go.mod h1:v4ULmyyV65geAZQBBckCjgMhmngTqz7HQVsQVYnfkGo= -github.com/pion/ice v0.7.1/go.mod h1:fPnWLWO3B83fJmO6Sci5Mv3ypN4Vd956Py4JlbJfVwU= -github.com/pion/logging v0.2.1/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= -github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= -github.com/pion/mdns v0.0.3/go.mod h1:VrN3wefVgtfL8QgpEblPUC46ag1reLIfpqekCnKunLE= -github.com/pion/quic v0.1.1/go.mod h1:zEU51v7ru8Mp4AUBJvj6psrSth5eEFNnVQK5K48oV3k= -github.com/pion/rtcp v1.2.1/go.mod h1:a5dj2d6BKIKHl43EnAOIrCczcjESrtPuMgfmL6/K6QM= -github.com/pion/rtp v1.1.3/go.mod h1:/l4cvcKd0D3u9JLs2xSVI95YkfXW87a3br3nqmVtSlE= -github.com/pion/rtp v1.1.4/go.mod h1:/l4cvcKd0D3u9JLs2xSVI95YkfXW87a3br3nqmVtSlE= -github.com/pion/sctp v1.7.2/go.mod h1:HlTD+15FeLYYQTTDO35uKEeRLVq5L2AY/ef6ZSvpIXc= -github.com/pion/sctp v1.7.3/go.mod h1:c6C9jaDGX7f5xeSRVju/140XatpO9sOVe81EwpfzAc8= -github.com/pion/sdp/v2 v2.3.1/go.mod h1:jccXVYW0fuK6ds2pwKr89SVBDYlCjhgMI6nucl5R5rA= -github.com/pion/srtp v1.2.6/go.mod h1:rd8imc5htjfs99XiEoOjLMEOcVjME63UHx9Ek9IGst0= -github.com/pion/stun v0.3.3/go.mod h1:xrCld6XM+6GWDZdvjPlLMsTU21rNxnO6UO8XsAvHr/M= -github.com/pion/transport v0.6.0/go.mod h1:iWZ07doqOosSLMhZ+FXUTq+TamDoXSllxpbGcfkCmbE= -github.com/pion/transport v0.8.9/go.mod h1:lpeSM6KJFejVtZf8k0fgeN7zE73APQpTF83WvA1FVP8= -github.com/pion/transport v0.8.10/go.mod h1:tBmha/UCjpum5hqTWhfAEs3CO4/tHSg0MYRhSzR+CZ8= -github.com/pion/turn v1.4.0/go.mod h1:aDSi6hWX/hd1+gKia9cExZOR0MU95O7zX9p3Gw/P2aU= -github.com/pion/webrtc/v2 v2.1.12/go.mod h1:CYstxYIn64VLKMmqTHgLvJRnYIF9Ofr4APJXsCVpeso= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/profile v1.4.0 h1:uCmaf4vVbWAOZz36k1hrQD7ijGRzLwaME8Am/7a4jZI= -github.com/pkg/profile v1.4.0/go.mod h1:NWz/XGvpEW1FyYQ7fCx4dqYBLlfTcE+A9FLAkNKqjFE= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -376,8 +337,6 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/prysmaticlabs/prysm v0.0.0-20191018160938-a05dca18c7f7 h1:i/B436AYjBc47qLSKoV+FUf/ff3JuJ+lBRkb2+z+7PM= -github.com/prysmaticlabs/prysm v0.0.0-20191018160938-a05dca18c7f7/go.mod h1:kjzJhe13tmXQBdaO5DRLntr1qtMgl1boIocbR4dP3O4= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday v2.0.0+incompatible h1:cBXrhZNUf9C+La9/YpS+UHpUT8YD6Td9ZMSU9APFcsk= @@ -387,11 +346,11 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/smira/go-statsd v1.3.1 h1:JalGiHNdK7GqVAPpg7j0Kwp2jZrz/fCg/B4ZuNuBY2w= -github.com/smira/go-statsd v1.3.1/go.mod h1:1srXJ9/pbnN04G8f4F1jUzsGOnwkPKXciyqpewGlkC4= github.com/smola/gocompat v0.2.0/go.mod h1:1B0MlxbmoZNo3h8guHp8HztB3BSYR5itql9qtVc0ypY= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spacemonkeygo/openssl v0.0.0-20181017203307-c2dcc5cca94a h1:/eS3yfGjQKG+9kayBkj0ip1BGhq6zJ3eaVksphxAaek= github.com/spacemonkeygo/openssl v0.0.0-20181017203307-c2dcc5cca94a/go.mod h1:7AyxJNCJ7SBZ1MfVQCWD6Uqo2oubI2Eq2y2eqf+A5r0= +github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 h1:RC6RW7j+1+HkWaX/Yh71Ee5ZHaHYt7ZP4sQgUrm6cDU= github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= @@ -422,12 +381,11 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= +github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/wedeploy/gosocketio v0.0.7-beta/go.mod h1:YMiI8XrJueRJAPy9+JSns95ZPOU1et26MMEZKLtv2D8= github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc h1:BCPnHtcboadS0DvysUuJXZ4lWVv5Bh5i7+tbIyi+ck4= github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc/go.mod h1:r45hJU7yEoA81k6MWNhpMj/kms0n14dkzkxYHoB96UM= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= @@ -460,16 +418,12 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8= -golang.org/x/arch v0.0.0-20190312162104-788fe5ffcd8c/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190618222545-ea8f1a30c443/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -479,7 +433,6 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/net v0.0.0-20180524181706-dfa909b99c79/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -489,12 +442,9 @@ golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190227160552-c95aed5357e7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190326090315-15845e8f865b/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190619014844-b5b0513f8c1b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191021144547-ec77196f6094 h1:5O4U9trLjNpuhpynaDsqwCk+Tw6seqJz1EbqbnzHrc8= golang.org/x/net v0.0.0-20191021144547-ec77196f6094/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -513,13 +463,9 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190228124157-a34e9553db1e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190322080309-f49334f85ddc/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191023151326-f89234f9a2c2 h1:I7efaDQAsIQmkTF+WSdcydwVWzK07Yuz8IFF8rNkDe0= -golang.org/x/sys v0.0.0-20191023151326-f89234f9a2c2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -528,11 +474,9 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181130052023-1c3d964395ce/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190106171756-3ef68632349c/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190325223049-1d95b17f1b04/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -548,6 +492,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/karalabe/cookiejar.v2 v2.0.0-20150724131613-8dcd6a7f4951 h1:DMTcQRFbEH62YPRWwOI647s2e5mHda3oBPMHfrLs2bw= gopkg.in/karalabe/cookiejar.v2 v2.0.0-20150724131613-8dcd6a7f4951/go.mod h1:owOxCRGGeAx1uugABik6K9oeNu1cgxP/R9ItzLDxNWA= @@ -556,6 +501,7 @@ gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3M gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/src-d/go-cli.v0 v0.0.0-20181105080154-d492247bbc0d/go.mod h1:z+K8VcOYVYcSwSjGebuDL6176A1XskgbtNl64NSg+n8= gopkg.in/src-d/go-log.v1 v1.0.1/go.mod h1:GN34hKP0g305ysm2/hctJ0Y8nWP3zxXXJ8GFabTyABE= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -563,4 +509,3 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= From bf0d20905b991b2799ee3b35b1064f323520871a Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Fri, 23 Jul 2021 14:12:28 -0400 Subject: [PATCH 17/20] theta: changes for v0.1.0 --- PUBLISHING.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 PUBLISHING.md diff --git a/PUBLISHING.md b/PUBLISHING.md new file mode 100644 index 00000000..b8f10421 --- /dev/null +++ b/PUBLISHING.md @@ -0,0 +1,15 @@ +``` +git add . +git commit -m "theta: changes for v0.1.0" +git tag v0.1.0 +git push origin v0.1.0 +GOPROXY=proxy.golang.org go list -m github.com/andrewlunde/theta-protocol-ledger@v0.1.0 + +go get github.com/andrewlunde/theta-protocol-ledger@v0.1.0 + +// in go.mod of application using this module +require github.com/thetatoken/theta v0.0.0 +replace github.com/thetatoken/theta v0.0.0 => github.com/andrewlunde/theta-protocol-ledger v0.1.0 + +``` + From dd7cc79e2cacc00e66c118fe16d1eaa80c9e3610 Mon Sep 17 00:00:00 2001 From: Andrew Lunde Date: Wed, 28 Jul 2021 18:41:29 -0400 Subject: [PATCH 18/20] added debugging flag --- cmd/thetacli/cmd/tx/main.go | 1 + cmd/thetacli/cmd/tx/reserve_fund.go | 15 ++++++ cmd/thetacli/cmd/tx/service_payment.go | 73 +++++++++++++++++++++++--- cmd/thetacli/test/batch.sh | 19 ++++--- ledger/types/tx.go | 28 +++++++--- version/version_generated.go | 4 +- 6 files changed, 118 insertions(+), 22 deletions(-) diff --git a/cmd/thetacli/cmd/tx/main.go b/cmd/thetacli/cmd/tx/main.go index e757442a..a6b051ff 100644 --- a/cmd/thetacli/cmd/tx/main.go +++ b/cmd/thetacli/cmd/tx/main.go @@ -40,6 +40,7 @@ var ( beneficiaryFlag string splitBasisPointFlag uint64 passwordFlag string + debuggingFlag bool ) // TxCmd represents the Tx command diff --git a/cmd/thetacli/cmd/tx/reserve_fund.go b/cmd/thetacli/cmd/tx/reserve_fund.go index 6dd203dd..b652d2a9 100644 --- a/cmd/thetacli/cmd/tx/reserve_fund.go +++ b/cmd/thetacli/cmd/tx/reserve_fund.go @@ -27,6 +27,21 @@ var reserveFundCmd = &cobra.Command{ } func doReserveFundCmd(cmd *cobra.Command, args []string) { + + + // formatted0, err0 := json.MarshalIndent(cmd, "", " ") + // if err0 != nil { + // utils.Error("Failed to parse server response: %v\n", err0) + // } + // //fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) + // // Verbose output makes parsing json difficult + // fmt.Printf("cmd: %s\n", formatted0) + + fmt.Printf("cmd: %s\n", cmd.Short) + fmt.Printf("config: %s\n", cmd.Flag("config").Value.String()) + + + wallet, fromAddress, err := walletUnlock(cmd, fromFlag, passwordFlag) if err != nil { return diff --git a/cmd/thetacli/cmd/tx/service_payment.go b/cmd/thetacli/cmd/tx/service_payment.go index d6b362eb..03042584 100644 --- a/cmd/thetacli/cmd/tx/service_payment.go +++ b/cmd/thetacli/cmd/tx/service_payment.go @@ -30,6 +30,10 @@ var servicePaymentCmd = &cobra.Command{ } func doServicePaymentCmd(cmd *cobra.Command, args []string) { + var debugging = false + if debuggingFlag { + debugging = true + } walletType := getWalletType(cmd) if walletType == wtypes.WalletTypeSoft && len(fromFlag) == 0 { utils.Error("The from address cannot be empty") // we don't need to specify the "from address" for hardware wallets @@ -53,6 +57,12 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { var toAddress = common.HexToAddress(toFlag) var err error + if (debugging) { + fmt.Printf("fromAddress: %s\n", fromAddress) + fmt.Printf("toAddress: %s\n", toAddress) + fmt.Printf("passwordFlag: %s\n", passwordFlag) + } + if onChainFlag { // if 1 == 1 { twallet, toAddress, err = walletUnlockWithPath(cmd, toFlag, pathFlag, passwordFlag) @@ -78,6 +88,11 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { utils.Error("Failed to parse fee") } + if (debugging) { + fmt.Printf("tfuel: %d\n", tfuel) + fmt.Printf("fee: %d\n", fee) + } + sinput := types.TxInput{ Address: fromAddress, Coins: types.Coins{ @@ -101,6 +116,12 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { //Signature: } + if (debugging) { + fmt.Printf("paymentSeqFlag: %d\n", paymentSeqFlag) + fmt.Printf("reserveSeqFlag: %d\n", reserveSeqFlag) + fmt.Printf("resourceIDFlag: %s\n", resourceIDFlag) + } + // See theta-protocol-ledger > ledger > types > tx.go : Line 522 servicePaymentTx := &types.ServicePaymentTx{ Fee: types.Coins{ @@ -116,6 +137,9 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { // Set the Source Signature if onChainFlag { + if (debugging) { + fmt.Printf("Set the Source Signature On-Chain\n") + } //ssig, err := crypto.UnmarshalJSON([]byte(sourceSignatureFlag)) ssig, err := crypto.SignatureFromBytes(common.FromHex(sourceSignatureFlag)) if err != nil { @@ -123,43 +147,78 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { } servicePaymentTx.SetSourceSignature(ssig) } else { + if (debugging) { + fmt.Printf("Set the Source Signature Off-Chain\n") + } ssig, err := swallet.Sign(fromAddress, servicePaymentTx.SourceSignBytes(chainIDFlag)) if err != nil { utils.Error("Failed to sign source transaction: %v\n", err) } + + //fmt.Printf("ssig: %s\n", ssig) servicePaymentTx.SetSourceSignature(ssig) + if (debugging) { + fmt.Printf("Set the Source Signature Off-Chain Finished\n") + } } // Set the Target Signature if onChainFlag { + if (debugging) { + fmt.Printf("Set the Target Signature On-Chain\n") + } tsig, err := twallet.Sign(toAddress, servicePaymentTx.TargetSignBytes(chainIDFlag)) if err != nil { utils.Error("Failed to sign target transaction: %v\n", err) } servicePaymentTx.SetTargetSignature(tsig) } else { + if (debugging) { + fmt.Printf("Set the Target Signature Off-Chain\n") + } tsig, err := crypto.SignatureFromBytes([]byte("unsigned")) if err != nil { utils.Error("Failed to convert passed signature: %v\n", err) } servicePaymentTx.SetTargetSignature(tsig) + if (debugging) { + fmt.Printf("Set the Target Signature Off-Chain Finished\n") + } + } + + if (debugging) { + formatted, err := json.MarshalIndent(servicePaymentTx, "", " ") + if err != nil { + utils.Error("Failed to parse off-chain transaction: %v\n", err) + } + fmt.Printf("Off-Chain transaction:\n%s\n", formatted) } raw, err := types.TxToBytes(servicePaymentTx) if err != nil { utils.Error("Failed to encode transaction: %v\n", err) } + + if (debugging) { + fmt.Printf(" raw: %s\n", hex.EncodeToString(raw)) + } + signedTx := hex.EncodeToString(raw) + if (debugging) { + fmt.Printf(" signedTx: %s\n", signedTx) + } + if onChainFlag { if dryRunFlag { - formatted, err := json.MarshalIndent(servicePaymentTx, "", " ") - if err != nil { - utils.Error("Failed to parse off-chain transaction: %v\n", err) + if (debugging) { + formatted, err := json.MarshalIndent(servicePaymentTx, "", " ") + if err != nil { + utils.Error("Failed to parse off-chain transaction: %v\n", err) + } + //fmt.Printf("On-Chain transaction(dry-run):\n%s\n", formatted) + fmt.Printf("%s\n", formatted) } - //fmt.Printf("On-Chain transaction(dry-run):\n%s\n", formatted) - fmt.Printf("%s\n", formatted) - } else { client := rpcc.NewRPCClient(viper.GetString(utils.CfgRemoteRPCEndpoint)) @@ -182,6 +241,7 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { if err != nil { utils.Error("Failed to parse server response: %v\n", err) } + formatted, err := json.MarshalIndent(result, "", " ") if err != nil { utils.Error("Failed to parse server response: %v\n", err) @@ -217,6 +277,7 @@ func init() { servicePaymentCmd.Flags().BoolVar(&asyncFlag, "async", false, "Block until tx has been included in the blockchain") servicePaymentCmd.Flags().StringVar(&passwordFlag, "password", "", "password to unlock the wallet") servicePaymentCmd.Flags().BoolVar(&dryRunFlag, "dry_run", false, "Dry Run(don't execute) the On-Chain transaction") + servicePaymentCmd.Flags().BoolVar(&debuggingFlag, "debugging", false, "Print verbose debugging output") servicePaymentCmd.MarkFlagRequired("chain") servicePaymentCmd.MarkFlagRequired("from") diff --git a/cmd/thetacli/test/batch.sh b/cmd/thetacli/test/batch.sh index 12c1d484..1a6b784d 100755 --- a/cmd/thetacli/test/batch.sh +++ b/cmd/thetacli/test/batch.sh @@ -4,8 +4,10 @@ do_run=1 # Execute(evaluate) the commands #do_run=0 # Don't evaluate any commands #do_echo=1 # Echo the commands do_echo=0 # Don't echo any commands -#do_echo_on_chain=1 # Echo the on-chain commands -do_echo_on_chain=0 # Don't echo, actually execute on-chain commands +do_echo_off_chain=1 # Echo the on-chain commands +#do_echo_off_chain=0 # Don't echo, actually execute on-chain commands +do_echo_on_chain=1 # Echo the on-chain commands +#do_echo_on_chain=0 # Don't echo, actually execute on-chain commands #calc_costs_only=1 # Only calculate the costs calc_costs_only=0 # Calculate the costs then run tx @@ -21,11 +23,12 @@ rfdurationblocks=30 # Reserve Fund Duration in blocktimes : Minimum for t let rfdurationsecs=10*60 # 10 minutes #let rfdurationsecs=3*60*60 # 3 hours -rfund=100 -rcoll=101 +rfund=1000 +rcoll=1001 #tfuel=0.1 -tfuel=0.3 +#tfuel=0.3 +tfuel=20 # total 10 items bobsigs=1 @@ -313,6 +316,7 @@ while [ $i -lt $bobsigs ]; do if [ $accumulate -eq 1 ]; then cmd='tfuelamt=$(echo "scale=3; ('$tfuelamt' + '$tfuel')/1" | bc -q 2>/dev/null)' if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_echo_off_chain -eq 1 ]; then echo $cmd; echo ""; fi if [ $do_run -eq 1 ]; then eval $cmd; fi else tfuelamt=$tfuel @@ -321,6 +325,7 @@ while [ $i -lt $bobsigs ]; do #cmd='sigout=$(./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$i' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' | tail -n +6 | jq .source.signature | tr -d '"'"'"'"'"')' cmd='sigout=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Bob' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --password=qwertyuiop | jq .source.signature | tr -d '"'"'"'"'"')' if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_echo_off_chain -eq 1 ]; then echo $cmd; echo ""; fi if [ $do_run -eq 1 ]; then eval $cmd; fi sigs+=($sigout) echo "" @@ -335,6 +340,7 @@ while [ $i -lt $carolsigs ]; do if [ $accumulate -eq 1 ]; then cmd='tfuelamt=$(echo "scale=3; ('$tfuelamt' + '$tfuel')/1" | bc -q 2>/dev/null)' if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_echo_off_chain -eq 1 ]; then echo $cmd; echo ""; fi if [ $do_run -eq 1 ]; then eval $cmd; fi else tfuelamt=$tfuel @@ -343,6 +349,7 @@ while [ $i -lt $carolsigs ]; do #cmd='sigout=$(./sp.sh --from='$Alice' --to='$Bob' --payment_seq='$i' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuel' | tail -n +6 | jq .source.signature | tr -d '"'"'"'"'"')' cmd='sigout=$(thetacli tx service_payment --chain="privatenet" --from='$Alice' --to='$Carol' --payment_seq='$payseq' --reserve_seq='$resseq' --resource_id='$rid' --tfuel='$tfuelamt' --password=qwertyuiop | jq .source.signature | tr -d '"'"'"'"'"')' if [ $do_echo -eq 1 ]; then echo $cmd; fi + if [ $do_echo_off_chain -eq 1 ]; then echo $cmd; echo ""; fi if [ $do_run -eq 1 ]; then eval $cmd; fi sigs+=($sigout) echo "" @@ -490,4 +497,4 @@ echo "" echo "Carol initial balance: "$(un_wei $cib) echo "Carol final balance : "$(un_wei $cax) echo "" -echo "Finished Batch Test." \ No newline at end of file +echo "Finished Batch Test." diff --git a/ledger/types/tx.go b/ledger/types/tx.go index 18964f3e..a5d47095 100644 --- a/ledger/types/tx.go +++ b/ledger/types/tx.go @@ -585,13 +585,16 @@ func (a *ServicePaymentTx) UnmarshalJSON(data []byte) error { func (_ *ServicePaymentTx) AssertIsTx() {} func (tx *ServicePaymentTx) SourceSignBytes(chainID string) []byte { + debugging := false signBytes := encodeToBytes(chainID) //formatted, err := json.MarshalIndent(result, "", " ") //if err != nil { // utils.Error("Failed : %v\n", err) //} - fmt.Printf("signBytes: %s\n", hex.EncodeToString(signBytes)) + if (debugging) { + fmt.Printf(" signBytes: %s\n", hex.EncodeToString(signBytes)) + } source := tx.Source target := tx.Target @@ -601,16 +604,22 @@ func (tx *ServicePaymentTx) SourceSignBytes(chainID string) []byte { tx.Target = TxInput{Address: target.Address} tx.Fee = NewCoins(0, 0) - formatted, err := json.MarshalIndent(tx, "", " ") - if err != nil { - fmt.Printf("Failed : %v\n", err) + if (debugging) { + formatted, err := json.MarshalIndent(tx, "", " ") + if err != nil { + fmt.Printf("Failed : %v\n", err) + } + fmt.Printf("tx to sign: %s\n", formatted) } - fmt.Printf("tx: %s\n", formatted) txBytes, _ := TxToBytes(tx) - fmt.Printf("txBytes: %s\n", hex.EncodeToString(txBytes)) + if (debugging) { + fmt.Printf(" txBytes: %s\n", hex.EncodeToString(txBytes)) + } signBytes = append(signBytes, txBytes...) - fmt.Printf("append signBytes: %s\n", hex.EncodeToString(signBytes)) + if (debugging) { + fmt.Printf(" append signBytes: %s\n", hex.EncodeToString(signBytes)) + } tx.Source = source tx.Target = target @@ -618,7 +627,10 @@ func (tx *ServicePaymentTx) SourceSignBytes(chainID string) []byte { signBytes = addPrefixForSignBytes(signBytes) - fmt.Printf("addPrefixForSignBytes: %s\n", hex.EncodeToString(signBytes)) + if (debugging) { + fmt.Printf(" bytesToBeSigned: %s\n", hex.EncodeToString(signBytes)) + } + return signBytes } diff --git a/version/version_generated.go b/version/version_generated.go index 92a300d1..63784639 100644 --- a/version/version_generated.go +++ b/version/version_generated.go @@ -1,6 +1,6 @@ package version const ( - Timestamp = "Wed Jul 21 20:40:34 UTC 2021" + Timestamp = "Wed Jul 28 20:00:19 UTC 2021" Version = "3.1.0" - GitHash = "3b39fa601ce500f0cbc742bcc9d41f7cecb34bcf" + GitHash = "bf0d20905b991b2799ee3b35b1064f323520871a" ) From 980d2ecd473d71930d1a3534c40204cd2f9b3b8f Mon Sep 17 00:00:00 2001 From: Jieyi Long Date: Sun, 15 Aug 2021 15:21:22 -0700 Subject: [PATCH 19/20] Some code clean-up --- NOTES.md | 208 ---- PUBLISHING.md | 15 - cmd/thetacli/cmd/root.go | 3 +- cmd/thetacli/cmd/tx/main.go | 2 +- .../TEST_RESULTS.md | 0 .../offchain_micropayment_test}/batch.sh | 0 tree.out | 1035 ----------------- version/{gitignore => .gitignore} | 0 version/version_generated.go | 6 - 9 files changed, 2 insertions(+), 1267 deletions(-) delete mode 100644 NOTES.md delete mode 100644 PUBLISHING.md rename {cmd/thetacli/test => integration/e2etest/offchain_micropayment_test}/TEST_RESULTS.md (100%) rename {cmd/thetacli/test => integration/e2etest/offchain_micropayment_test}/batch.sh (100%) delete mode 100644 tree.out rename version/{gitignore => .gitignore} (100%) delete mode 100644 version/version_generated.go diff --git a/NOTES.md b/NOTES.md deleted file mode 100644 index 76142bdc..00000000 --- a/NOTES.md +++ /dev/null @@ -1,208 +0,0 @@ -``` -$ thetacli query account --address=2E833968E5bB786Ae419c4d13189fB081Cc43bab -Using config file: /Users/i830671/.thetacli/config.yaml -{ - "code": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", - "coins": { - "tfuelwei": "312499798999999000000000000", - "thetawei": "12500000000000000000000000" - }, - "last_updated_block_height": "0", - "reserved_funds": [ - { - "collateral": { - "tfuelwei": "101000000000000000000", - "thetawei": "0" - }, - "end_block_height": "1428", - "initial_fund": { - "tfuelwei": "100000000000000000000", - "thetawei": "0" - }, - "reserve_sequence": "1", - "resource_ids": [ - "rid1000001" - ], - "transfer_records": [], - "used_fund": { - "tfuelwei": "0", - "thetawei": "0" - } - } - ], - "root": "0x0000000000000000000000000000000000000000000000000000000000000000", - "sequence": "1" -} -``` -// From unit tests -// theta-protocol-ledger > ledger > execution > regular_ty_execution_test.go : Line 723 - - -func TestServicePaymentTxNormalExecutionAndSlash(t *testing.T) { - assert := assert.New(t) - - // This sets up 3 accounts with alice reserving funds on hers - et, resourceID, alice, bob, carol, _, bobInitBalance, carolInitBalance := setupForServicePayment(assert) - et.state().Commit() - - txFee := getMinimumTxFee() - -// Query Alices' account make sure she has a single reserve fund - retrievedAliceAcc0 := et.state().Delivered().GetAccount(alice.Address) - assert.Equal(1, len(retrievedAliceAcc0.ReservedFunds)) - assert.Equal([]string{resourceID}, retrievedAliceAcc0.ReservedFunds[0].ResourceIDs) - assert.Equal(types.Coins{TFuelWei: big.NewInt(1001 * txFee), ThetaWei: big.NewInt(0)}, retrievedAliceAcc0.ReservedFunds[0].Collateral) - assert.Equal(uint64(1), retrievedAliceAcc0.ReservedFunds[0].ReserveSequence) - - // Simulate micropayment #1 between Alice and Bob - payAmount1 := int64(80 * txFee) - srcSeq, tgtSeq, paymentSeq, reserveSeq := 1, 1, 1, 1 - _ = createServicePaymentTx(et.chainID, &alice, &bob, 10*txFee, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) - _ = createServicePaymentTx(et.chainID, &alice, &bob, 50*txFee, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) - - servicePaymentTx1 := createServicePaymentTx(et.chainID, &alice, &bob, payAmount1, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) - - res := et.executor.getTxExecutor(servicePaymentTx1).sanityCheck(et.chainID, et.state().Delivered(), servicePaymentTx1) - - assert.True(res.IsOK(), res.Message) - _, res = et.executor.getTxExecutor(servicePaymentTx1).process(et.chainID, et.state().Delivered(), servicePaymentTx1) - - assert.True(res.IsOK(), res.Message) - assert.Equal(0, len(et.state().Delivered().GetSlashIntents())) - - et.state().Commit() - - retrievedAliceAcc1 := et.state().Delivered().GetAccount(alice.Address) - - assert.Equal(types.Coins{TFuelWei: big.NewInt(payAmount1), ThetaWei: big.NewInt(0)}, retrievedAliceAcc1.ReservedFunds[0].UsedFund) - retrievedBobAcc1 := et.state().Delivered().GetAccount(bob.Address) - assert.Equal(bobInitBalance.Plus(types.Coins{TFuelWei: big.NewInt(payAmount1 - txFee), ThetaWei: big.NewInt(0)}), retrievedBobAcc1.Balance) // payAmount1 - txFee: need to account for tx fee - - // Simulate micropayment #2 between Alice and Bob - payAmount2 := int64(50 * txFee) - srcSeq, tgtSeq, paymentSeq, reserveSeq = 1, 2, 2, 1 - _ = createServicePaymentTx(et.chainID, &alice, &bob, 30*txFee, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) - servicePaymentTx2 := createServicePaymentTx(et.chainID, &alice, &bob, payAmount2, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) - res = et.executor.getTxExecutor(servicePaymentTx2).sanityCheck(et.chainID, et.state().Delivered(), servicePaymentTx2) - assert.True(res.IsOK(), res.Message) - _, res = et.executor.getTxExecutor(servicePaymentTx2).process(et.chainID, et.state().Delivered(), servicePaymentTx2) - assert.True(res.IsOK(), res.Message) - assert.Equal(0, len(et.state().Delivered().GetSlashIntents())) - - et.state().Commit() - - retrievedAliceAcc2 := et.state().Delivered().GetAccount(alice.Address) - assert.Equal(types.Coins{TFuelWei: big.NewInt(payAmount1 + payAmount2), ThetaWei: big.NewInt(0)}, retrievedAliceAcc2.ReservedFunds[0].UsedFund) - retrievedBobAcc2 := et.state().Delivered().GetAccount(bob.Address) - assert.Equal(bobInitBalance.Plus(types.Coins{TFuelWei: big.NewInt(payAmount1 + payAmount2 - 2*txFee)}), retrievedBobAcc2.Balance) // payAmount1 + payAmount2 - 2*txFee: need to account for tx fee - - // Simulate micropayment #3 between Alice and Carol - payAmount3 := int64(120 * txFee) - srcSeq, tgtSeq, paymentSeq, reserveSeq = 1, 1, 3, 1 - _ = createServicePaymentTx(et.chainID, &alice, &carol, 30*txFee, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) - servicePaymentTx3 := createServicePaymentTx(et.chainID, &alice, &carol, payAmount3, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) - res = et.executor.getTxExecutor(servicePaymentTx3).sanityCheck(et.chainID, et.state().Delivered(), servicePaymentTx3) - assert.True(res.IsOK(), res.Message) - _, res = et.executor.getTxExecutor(servicePaymentTx3).process(et.chainID, et.state().Delivered(), servicePaymentTx3) - assert.True(res.IsOK(), res.Message) - assert.Equal(0, len(et.state().Delivered().GetSlashIntents())) - - et.state().Commit() - - retrievedAliceAcc3 := et.state().Delivered().GetAccount(alice.Address) - assert.Equal(types.Coins{TFuelWei: big.NewInt(payAmount1 + payAmount2 + payAmount3), ThetaWei: big.NewInt(0)}, retrievedAliceAcc3.ReservedFunds[0].UsedFund) - retrievedCarolAcc3 := et.state().Delivered().GetAccount(carol.Address) - assert.Equal(carolInitBalance.Plus(types.Coins{TFuelWei: big.NewInt(payAmount3 - txFee)}), retrievedCarolAcc3.Balance) // payAmount3 - txFee: need to account for tx fee - - // Simulate micropayment #4 between Alice and Carol. This is an overspend, alice should get slashed. - payAmount4 := int64(2000 * txFee) - srcSeq, tgtSeq, paymentSeq, reserveSeq = 1, 2, 4, 1 - _ = createServicePaymentTx(et.chainID, &alice, &carol, 70000*txFee, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) - servicePaymentTx4 := createServicePaymentTx(et.chainID, &alice, &carol, payAmount4, srcSeq, tgtSeq, paymentSeq, reserveSeq, resourceID) - res = et.executor.getTxExecutor(servicePaymentTx4).sanityCheck(et.chainID, et.state().Delivered(), servicePaymentTx4) - assert.True(res.IsOK(), res.Message) // the following process() call will create an SlashIntent - - assert.Equal(0, len(et.state().Delivered().GetSlashIntents())) - _, res = et.executor.getTxExecutor(servicePaymentTx4).process(et.chainID, et.state().Delivered(), servicePaymentTx4) - assert.True(res.IsOK(), res.Message) - //assert.Equal(1, len(et.state().Delivered().GetSlashIntents())) - - -// Set up for Off-Chain testing - -thetacli query account --address=2E833968E5bB786Ae419c4d13189fB081Cc43bab - - -thetacli tx reserve --async --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --fund=10 --collateral=11 --duration=31 --resource_ids=rid1000001 --seq=1 - -thetacli tx send --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --theta=0 --tfuel=1 --seq=2 - -thetacli query account --address=2E833968E5bB786Ae419c4d13189fB081Cc43bab - -thetacli query account --address=70f587259738cB626A1720Af7038B8DcDb6a42a0 - -// Alice : I want rid1000001 and I'm willing to pay up to 10 TFuel for it. -thetacli query account --address=2E833968E5bB786Ae419c4d13189fB081Cc43bab - -thetacli tx reserve --async --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --fund=10 --collateral=11 --duration=101 --resource_ids=rid1000001 --seq=12 - -thetacli query account --address=2E833968E5bB786Ae419c4d13189fB081Cc43bab - -"hash": "0x4bb258b6784ec0a755e5ab7dfb50403a462866ebac3d27c96463b2a1becd65ca" - -thetacli query tx --hash=0x3d38c3851ae49072400b9f4c63fea1511b600552ff0eed4f008eb1d5cec5013a - -// Alice -> Bob -"end_block_height": "1533" -thetacli query tx --hash=0x29745a458dc5e1f39a511b889f04396d1add0a16ad279816b46dfa496b1fa228 -// Alice <- Bob ---resource_id=rid1000001 - -// Alice -> Bob -thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=8 --resource_id=rid1000001 --tfuel=2 - ---resource_id=rid1000001 - -thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=2 --reserve_seq=12 --resource_id=rid1000001 --tfuel=2 - -// Alice -> Carol -thetacli query tx --hash=0x29745a458dc5e1f39a511b889f04396d1add0a16ad279816b46dfa496b1fa228 -// Alice <- Carol ---resource_id=rid1000001 - -// Alice -> Carol -thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 --payment_seq=3 --reserve_seq=12 --resource_id=rid1000001 --tfuel=2 - ---resource_id=rid1000001 - -thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 --payment_seq=4 --reserve_seq=13 --resource_id=rid1000001 --tfuel=4 - - -// Bob -> Payout -thetacli query tx --hash=0x3d38c3851ae49072400b9f4c63fea1511b600552ff0eed4f008eb1d5cec5013a - -thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=1 --reserve_seq=8 --resource_id=rid1000001 --tfuel=2 --on_chain --src_sig=0x9bc43df9cfb50a0284161543709a3cad4d55a42ad74e2e8520af74730a9977b835aa976803a473451ca109c4032b8c947d7edb8499c949a6926231db8b4f53c900 - -thetacli query account --address=70f587259738cB626A1720Af7038B8DcDb6a42a0 - -// Carol -> Payout -thetacli query tx --hash=0x3d38c3851ae49072400b9f4c63fea1511b600552ff0eed4f008eb1d5cec5013a - -thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 --payment_seq=4 --reserve_seq=12 --resource_id=rid1000001 --tfuel=4 --on_chain --src_sig=0x1114ce5922a7e940542468fc2b6cd22f779408224310d63eb6215171e8618daf53432533b207704dcd2d21235a8e40e84819df369154b01f7a47357e496250e801 - -thetacli query account --address=0xcd56123D0c5D6C1Ba4D39367b88cba61D93F5405 - - - - -thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=2 --reserve_seq=8 --resource_id=rid1000001 --tfuel=2 - -thetacli tx service_payment --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --to=70f587259738cB626A1720Af7038B8DcDb6a42a0 --payment_seq=2 --reserve_seq=8 --resource_id=rid1000001 --tfuel=2 --on_chain --src_sig=0x9e2ff11e85636b8aece02127db7b9bfa4ffdff144a026f99aeb6f375d0c21ec244618896410d3bad9eaad560162ffb8c00b6906ef9a424a2354173342119a00201 - -0x12bd5090066cb508b50c437faba261afca2ed1c985812a2f7e4d2a6321d9128c33a5456c4105ceafb3da7897cfb97b50e6ff70e1ba7aaf0ba562890246ec728801 - -thetacli tx release --chain="privatenet" --from=2E833968E5bB786Ae419c4d13189fB081Cc43bab --reserve_seq=17 --seq=18 -Using config file: /Users/i830671/.thetacli/config.yaml -Please enter password: -Server returned error: -32000: Fund cannot be released until blockheight 3051 - diff --git a/PUBLISHING.md b/PUBLISHING.md deleted file mode 100644 index b8f10421..00000000 --- a/PUBLISHING.md +++ /dev/null @@ -1,15 +0,0 @@ -``` -git add . -git commit -m "theta: changes for v0.1.0" -git tag v0.1.0 -git push origin v0.1.0 -GOPROXY=proxy.golang.org go list -m github.com/andrewlunde/theta-protocol-ledger@v0.1.0 - -go get github.com/andrewlunde/theta-protocol-ledger@v0.1.0 - -// in go.mod of application using this module -require github.com/thetatoken/theta v0.0.0 -replace github.com/thetatoken/theta v0.0.0 => github.com/andrewlunde/theta-protocol-ledger v0.1.0 - -``` - diff --git a/cmd/thetacli/cmd/root.go b/cmd/thetacli/cmd/root.go index f07bb989..4b1df1aa 100644 --- a/cmd/thetacli/cmd/root.go +++ b/cmd/thetacli/cmd/root.go @@ -62,8 +62,7 @@ func initConfig() { // If a config file is found, read it in. if err := viper.ReadInConfig(); err == nil { - // Noisey output causes output parsing difficulty - //fmt.Println("Using config file:", viper.ConfigFileUsed()) + fmt.Println("Using config file:", viper.ConfigFileUsed()) } } diff --git a/cmd/thetacli/cmd/tx/main.go b/cmd/thetacli/cmd/tx/main.go index a6b051ff..7853d7b0 100644 --- a/cmd/thetacli/cmd/tx/main.go +++ b/cmd/thetacli/cmd/tx/main.go @@ -54,7 +54,7 @@ func init() { TxCmd.AddCommand(sendCmd) TxCmd.AddCommand(reserveFundCmd) TxCmd.AddCommand(servicePaymentCmd) - TxCmd.AddCommand(releaseFundCmd) // No need for releaseFundCmd since auto-release is already implemented + //TxCmd.AddCommand(releaseFundCmd) // No need for releaseFundCmd since auto-release is already implemented TxCmd.AddCommand(splitRuleCmd) TxCmd.AddCommand(smartContractCmd) TxCmd.AddCommand(depositStakeCmd) diff --git a/cmd/thetacli/test/TEST_RESULTS.md b/integration/e2etest/offchain_micropayment_test/TEST_RESULTS.md similarity index 100% rename from cmd/thetacli/test/TEST_RESULTS.md rename to integration/e2etest/offchain_micropayment_test/TEST_RESULTS.md diff --git a/cmd/thetacli/test/batch.sh b/integration/e2etest/offchain_micropayment_test/batch.sh similarity index 100% rename from cmd/thetacli/test/batch.sh rename to integration/e2etest/offchain_micropayment_test/batch.sh diff --git a/tree.out b/tree.out deleted file mode 100644 index 355b025f..00000000 --- a/tree.out +++ /dev/null @@ -1,1035 +0,0 @@ -. -├── Dockerfile -├── LICENSE -├── Makefile -├── README.md -├── blockchain -│   ├── chain.go -│   ├── chain_test.go -│   ├── testutil.go -│   ├── tx.go -│   ├── tx_test.go -│   ├── util_test.go -│   ├── vote.go -│   └── vote_test.go -├── cmd -│   ├── theta -│   │   ├── cmd -│   │   │   ├── init.go -│   │   │   ├── root.go -│   │   │   ├── start.go -│   │   │   └── version.go -│   │   └── main.go -│   └── thetacli -│   ├── cmd -│   │   ├── backup -│   │   │   ├── chain.go -│   │   │   ├── correction.go -│   │   │   ├── main.go -│   │   │   └── snapshot.go -│   │   ├── call -│   │   │   ├── main.go -│   │   │   └── smart_contract.go -│   │   ├── daemon -│   │   │   ├── daemon.go -│   │   │   └── main.go -│   │   ├── key -│   │   │   ├── delete.go -│   │   │   ├── list.go -│   │   │   ├── main.go -│   │   │   ├── new.go -│   │   │   ├── password.go -│   │   │   └── recover.go -│   │   ├── query -│   │   │   ├── account.go -│   │   │   ├── block.go -│   │   │   ├── gcp.go -│   │   │   ├── guardian.go -│   │   │   ├── main.go -│   │   │   ├── peers.go -│   │   │   ├── split_rule.go -│   │   │   ├── status.go -│   │   │   ├── tx.go -│   │   │   ├── vcp.go -│   │   │   └── version.go -│   │   ├── root.go -│   │   ├── tx -│   │   │   ├── deposit_stake.go -│   │   │   ├── main.go -│   │   │   ├── release_fund.go -│   │   │   ├── reserve_fund.go -│   │   │   ├── send.go -│   │   │   ├── smart_contract.go -│   │   │   ├── split_rule.go -│   │   │   ├── utils.go -│   │   │   └── withdraw_stake.go -│   │   ├── utils -│   │   │   ├── config.go -│   │   │   └── utils.go -│   │   └── version.go -│   ├── main.go -│   └── rpc -│   ├── key.go -│   ├── server.go -│   └── tx.go -├── common -│   ├── async.go -│   ├── big.go -│   ├── bytes.go -│   ├── bytes_test.go -│   ├── clist -│   │   ├── clist.go -│   │   └── clist_test.go -│   ├── config.go -│   ├── go.mod -│   ├── go.sum -│   ├── heights.go -│   ├── hexutil -│   │   ├── hexutil.go -│   │   ├── hexutil_test.go -│   │   ├── json.go -│   │   ├── json_example_test.go -│   │   └── json_test.go -│   ├── json.go -│   ├── json_test.go -│   ├── math -│   │   ├── big.go -│   │   ├── big_test.go -│   │   ├── integer.go -│   │   ├── integer_test.go -│   │   └── minmax.go -│   ├── metrics -│   │   ├── FORK.md -│   │   ├── LICENSE -│   │   ├── README.md -│   │   ├── counter.go -│   │   ├── counter_test.go -│   │   ├── debug.go -│   │   ├── debug_test.go -│   │   ├── disk.go -│   │   ├── disk_linux.go -│   │   ├── disk_nop.go -│   │   ├── ewma.go -│   │   ├── ewma_test.go -│   │   ├── exp -│   │   │   └── exp.go -│   │   ├── gauge.go -│   │   ├── gauge_float64.go -│   │   ├── gauge_float64_test.go -│   │   ├── gauge_test.go -│   │   ├── graphite.go -│   │   ├── graphite_test.go -│   │   ├── healthcheck.go -│   │   ├── histogram.go -│   │   ├── histogram_test.go -│   │   ├── init_test.go -│   │   ├── json.go -│   │   ├── json_test.go -│   │   ├── librato -│   │   │   ├── client.go -│   │   │   └── librato.go -│   │   ├── log.go -│   │   ├── memory.md -│   │   ├── meter.go -│   │   ├── meter_test.go -│   │   ├── metrics.go -│   │   ├── metrics_test.go -│   │   ├── opentsdb.go -│   │   ├── opentsdb_test.go -│   │   ├── registry.go -│   │   ├── registry_test.go -│   │   ├── resetting_timer.go -│   │   ├── resetting_timer_test.go -│   │   ├── runtime.go -│   │   ├── runtime_cgo.go -│   │   ├── runtime_gccpufraction.go -│   │   ├── runtime_no_cgo.go -│   │   ├── runtime_no_gccpufraction.go -│   │   ├── runtime_test.go -│   │   ├── sample.go -│   │   ├── sample_test.go -│   │   ├── syslog.go -│   │   ├── timer.go -│   │   ├── timer_test.go -│   │   ├── validate.sh -│   │   ├── writer.go -│   │   └── writer_test.go -│   ├── os.go -│   ├── pqueue -│   │   ├── priority_queue.go -│   │   └── priority_queue_test.go -│   ├── result -│   │   ├── error_code.go -│   │   └── result.go -│   ├── timer -│   │   ├── repeat_timer.go -│   │   └── throttle_timer.go -│   ├── types.go -│   ├── types_test.go -│   └── util -│   ├── formatter.go -│   ├── ip.go -│   ├── log.go -│   ├── log_test.go -│   ├── misc.go -│   └── sample.go -├── consensus -│   ├── engine.go -│   ├── engine_test.go -│   ├── guardian.go -│   ├── guardian_test.go -│   ├── state.go -│   ├── state_test.go -│   ├── testutil.go -│   └── validator.go -├── core -│   ├── backup.go -│   ├── block.go -│   ├── block_test.go -│   ├── bloom.go -│   ├── consensus.go -│   ├── genesis.go -│   ├── guardian.go -│   ├── guardian_test.go -│   ├── hardcode_block_hashes.go -│   ├── ledger.go -│   ├── snapshot.go -│   ├── stake.go -│   ├── stake_test.go -│   ├── testutil.go -│   ├── validator.go -│   ├── validator_test.go -│   ├── vote.go -│   └── vote_test.go -├── crypto -│   ├── bls -│   │   ├── bls.go -│   │   ├── bls_benchmark_test.go -│   │   └── bls_test.go -│   ├── bn256 -│   │   ├── LICENSE -│   │   ├── bn256_fast.go -│   │   ├── bn256_fuzz.go -│   │   ├── bn256_slow.go -│   │   ├── cloudflare -│   │   │   ├── LICENSE -│   │   │   ├── bn256.go -│   │   │   ├── bn256_test.go -│   │   │   ├── constants.go -│   │   │   ├── curve.go -│   │   │   ├── example_test.go -│   │   │   ├── gfp.go -│   │   │   ├── gfp12.go -│   │   │   ├── gfp2.go -│   │   │   ├── gfp6.go -│   │   │   ├── gfp_amd64.s -│   │   │   ├── gfp_arm64.s -│   │   │   ├── gfp_decl.go -│   │   │   ├── gfp_generic.go -│   │   │   ├── gfp_test.go -│   │   │   ├── lattice.go -│   │   │   ├── lattice_test.go -│   │   │   ├── main_test.go -│   │   │   ├── mul_amd64.h -│   │   │   ├── mul_arm64.h -│   │   │   ├── mul_bmi2_amd64.h -│   │   │   ├── optate.go -│   │   │   └── twist.go -│   │   └── google -│   │   ├── bn256.go -│   │   ├── bn256_test.go -│   │   ├── constants.go -│   │   ├── curve.go -│   │   ├── example_test.go -│   │   ├── gfp12.go -│   │   ├── gfp2.go -│   │   ├── gfp6.go -│   │   ├── main_test.go -│   │   ├── optate.go -│   │   └── twist.go -│   ├── crypto.go -│   ├── crypto_test.go -│   ├── ecies -│   │   ├── LICENSE -│   │   ├── README -│   │   ├── ecies.go -│   │   ├── ecies_test.go -│   │   └── params.go -│   ├── keyutils.go -│   ├── keyutils_test.go -│   ├── secp256k1 -│   │   ├── LICENSE -│   │   ├── curve.go -│   │   ├── ext.h -│   │   ├── libsecp256k1 -│   │   │   ├── COPYING -│   │   │   ├── Makefile.am -│   │   │   ├── README.md -│   │   │   ├── TODO -│   │   │   ├── autogen.sh -│   │   │   ├── build-aux -│   │   │   │   └── m4 -│   │   │   │   ├── ax_jni_include_dir.m4 -│   │   │   │   ├── ax_prog_cc_for_build.m4 -│   │   │   │   └── bitcoin_secp.m4 -│   │   │   ├── configure.ac -│   │   │   ├── contrib -│   │   │   │   ├── lax_der_parsing.c -│   │   │   │   ├── lax_der_parsing.h -│   │   │   │   ├── lax_der_privatekey_parsing.c -│   │   │   │   └── lax_der_privatekey_parsing.h -│   │   │   ├── include -│   │   │   │   ├── secp256k1.h -│   │   │   │   ├── secp256k1_ecdh.h -│   │   │   │   └── secp256k1_recovery.h -│   │   │   ├── libsecp256k1.pc.in -│   │   │   ├── obj -│   │   │   ├── sage -│   │   │   │   ├── group_prover.sage -│   │   │   │   ├── secp256k1.sage -│   │   │   │   └── weierstrass_prover.sage -│   │   │   └── src -│   │   │   ├── asm -│   │   │   │   └── field_10x26_arm.s -│   │   │   ├── basic-config.h -│   │   │   ├── bench.h -│   │   │   ├── bench_ecdh.c -│   │   │   ├── bench_internal.c -│   │   │   ├── bench_recover.c -│   │   │   ├── bench_schnorr_verify.c -│   │   │   ├── bench_sign.c -│   │   │   ├── bench_verify.c -│   │   │   ├── ecdsa.h -│   │   │   ├── ecdsa_impl.h -│   │   │   ├── eckey.h -│   │   │   ├── eckey_impl.h -│   │   │   ├── ecmult.h -│   │   │   ├── ecmult_const.h -│   │   │   ├── ecmult_const_impl.h -│   │   │   ├── ecmult_gen.h -│   │   │   ├── ecmult_gen_impl.h -│   │   │   ├── ecmult_impl.h -│   │   │   ├── field.h -│   │   │   ├── field_10x26.h -│   │   │   ├── field_10x26_impl.h -│   │   │   ├── field_5x52.h -│   │   │   ├── field_5x52_asm_impl.h -│   │   │   ├── field_5x52_impl.h -│   │   │   ├── field_5x52_int128_impl.h -│   │   │   ├── field_impl.h -│   │   │   ├── gen_context.c -│   │   │   ├── group.h -│   │   │   ├── group_impl.h -│   │   │   ├── hash.h -│   │   │   ├── hash_impl.h -│   │   │   ├── java -│   │   │   │   ├── org -│   │   │   │   │   └── bitcoin -│   │   │   │   │   ├── NativeSecp256k1.java -│   │   │   │   │   ├── NativeSecp256k1Test.java -│   │   │   │   │   ├── NativeSecp256k1Util.java -│   │   │   │   │   └── Secp256k1Context.java -│   │   │   │   ├── org_bitcoin_NativeSecp256k1.c -│   │   │   │   ├── org_bitcoin_NativeSecp256k1.h -│   │   │   │   ├── org_bitcoin_Secp256k1Context.c -│   │   │   │   └── org_bitcoin_Secp256k1Context.h -│   │   │   ├── modules -│   │   │   │   ├── ecdh -│   │   │   │   │   ├── Makefile.am.include -│   │   │   │   │   ├── main_impl.h -│   │   │   │   │   └── tests_impl.h -│   │   │   │   └── recovery -│   │   │   │   ├── Makefile.am.include -│   │   │   │   ├── main_impl.h -│   │   │   │   └── tests_impl.h -│   │   │   ├── num.h -│   │   │   ├── num_gmp.h -│   │   │   ├── num_gmp_impl.h -│   │   │   ├── num_impl.h -│   │   │   ├── scalar.h -│   │   │   ├── scalar_4x64.h -│   │   │   ├── scalar_4x64_impl.h -│   │   │   ├── scalar_8x32.h -│   │   │   ├── scalar_8x32_impl.h -│   │   │   ├── scalar_impl.h -│   │   │   ├── scalar_low.h -│   │   │   ├── scalar_low_impl.h -│   │   │   ├── secp256k1.c -│   │   │   ├── testrand.h -│   │   │   ├── testrand_impl.h -│   │   │   ├── tests.c -│   │   │   ├── tests_exhaustive.c -│   │   │   └── util.h -│   │   ├── panic_cb.go -│   │   ├── secp256.go -│   │   └── secp256_test.go -│   ├── sha3 -│   │   ├── LICENSE -│   │   ├── PATENTS -│   │   ├── doc.go -│   │   ├── hashes.go -│   │   ├── keccakf.go -│   │   ├── keccakf_amd64.go -│   │   ├── keccakf_amd64.s -│   │   ├── register.go -│   │   ├── sha3.go -│   │   ├── sha3_test.go -│   │   ├── shake.go -│   │   ├── testdata -│   │   │   └── keccakKats.json.deflate -│   │   ├── xor.go -│   │   ├── xor_generic.go -│   │   └── xor_unaligned.go -│   ├── signatureutils.go -│   ├── signatureutils_test.go -│   └── testutils.go -├── dispatcher -│   ├── dispatcher.go -│   └── types.go -├── docs -│   ├── commands -│   │   ├── generator.exe -│   │   ├── generator.go -│   │   ├── ledger -│   │   │   ├── theta.md -│   │   │   ├── theta_init.md -│   │   │   ├── theta_start.md -│   │   │   └── theta_version.md -│   │   ├── walker.go -│   │   └── wallet -│   │   ├── thetacli.md -│   │   ├── thetacli_backup.md -│   │   ├── thetacli_backup_chain.md -│   │   ├── thetacli_backup_snapshot.md -│   │   ├── thetacli_call.md -│   │   ├── thetacli_call_smart_contract.md -│   │   ├── thetacli_daemon.md -│   │   ├── thetacli_daemon_start.md -│   │   ├── thetacli_key.md -│   │   ├── thetacli_key_delete.md -│   │   ├── thetacli_key_list.md -│   │   ├── thetacli_key_new.md -│   │   ├── thetacli_key_password.md -│   │   ├── thetacli_query.md -│   │   ├── thetacli_query_account.md -│   │   ├── thetacli_query_block.md -│   │   ├── thetacli_query_split_rule.md -│   │   ├── thetacli_query_status.md -│   │   ├── thetacli_query_tx.md -│   │   ├── thetacli_query_vcp.md -│   │   ├── thetacli_query_version.md -│   │   ├── thetacli_tx.md -│   │   ├── thetacli_tx_deposit.md -│   │   ├── thetacli_tx_reserve.md -│   │   ├── thetacli_tx_send.md -│   │   ├── thetacli_tx_smart_contract.md -│   │   ├── thetacli_tx_split_rule.md -│   │   └── thetacli_tx_withdraw.md -│   ├── multi-level-bft-tech-report.pdf -│   └── theta-technical-whitepaper.pdf -├── glide.lock -├── glide.yaml -├── go.mod -├── go.sum -├── integration -│   ├── build -│   │   └── build.sh -│   ├── docker -│   │   ├── build -│   │   │   ├── Dockerfile -│   │   │   ├── README.md -│   │   │   ├── build.sh -│   │   │   └── start.sh -│   │   └── node -│   │   ├── Dockerfile -│   │   ├── README.md -│   │   ├── build.sh -│   │   └── start.sh -│   ├── e2etest -│   │   └── eth_keypair_compatibility_test -│   │   ├── batch_test.py -│   │   └── new_account_password.txt -│   ├── mainnet -│   │   ├── validator -│   │   │   ├── config.yaml -│   │   │   ├── genesis -│   │   │   └── snapshot -│   │   └── walletnode -│   │   ├── config.yaml -│   │   ├── genesis -│   │   └── snapshot -│   ├── privatenet -│   │   ├── node -│   │   │   ├── config.yaml -│   │   │   ├── data -│   │   │   │   ├── genesis_signatures.json -│   │   │   │   ├── genesis_stake_deposit.json -│   │   │   │   ├── genesis_theta_erc20_snapshot.json -│   │   │   │   └── theta-balance-height-7160047.json -│   │   │   ├── genesis -│   │   │   ├── genesis.bak -│   │   │   ├── key -│   │   │   │   └── encrypted -│   │   │   │   └── 2E833968E5bB786Ae419c4d13189fB081Cc43bab -│   │   │   └── snapshot -│   │   └── thetacli -│   │   └── keys -│   │   ├── encrypted -│   │   │   ├── 0d2fD67d573c8ecB4161510fc00754d64B401F86 -│   │   │   ├── 21cA457E6E34162654aDEe28bcf235ebE5eee5De -│   │   │   ├── 2E833968E5bB786Ae419c4d13189fB081Cc43bab -│   │   │   ├── 70f587259738cB626A1720Af7038B8DcDb6a42a0 -│   │   │   ├── a5cdB2B0306518fb37b28bb63A1B2590FdE9b747 -│   │   │   └── cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 -│   │   └── plain -│   │   ├── 0d2fD67d573c8ecB4161510fc00754d64B401F86 -│   │   ├── 21cA457E6E34162654aDEe28bcf235ebE5eee5De -│   │   ├── 2E833968E5bB786Ae419c4d13189fB081Cc43bab -│   │   ├── 70f587259738cB626A1720Af7038B8DcDb6a42a0 -│   │   ├── a5cdB2B0306518fb37b28bb63A1B2590FdE9b747 -│   │   └── cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 -│   ├── testnet -│   │   ├── README.md -│   │   ├── extra -│   │   │   └── 7validators -│   │   │   ├── node5 -│   │   │   │   ├── config.yaml -│   │   │   │   ├── genesis -│   │   │   │   ├── key -│   │   │   │   │   └── encrypted -│   │   │   │   │   └── 5F74E3D5cc77b66F0030C5501CFBd39dcB8fF5b6 -│   │   │   │   ├── key.plain -│   │   │   │   └── snapshot -│   │   │   ├── node6 -│   │   │   │   ├── config.yaml -│   │   │   │   ├── genesis -│   │   │   │   ├── key -│   │   │   │   │   └── encrypted -│   │   │   │   │   └── DfB095B990C98A96dD434fe45Cd040EC2167C228 -│   │   │   │   ├── key.plain -│   │   │   │   └── snapshot -│   │   │   └── node7 -│   │   │   ├── config.yaml -│   │   │   ├── genesis -│   │   │   ├── key -│   │   │   │   └── encrypted -│   │   │   │   └── 350ddEf232565b32E66A9fB69780E85b686A9E1d -│   │   │   ├── key.plain -│   │   │   └── snapshot -│   │   ├── node1 -│   │   │   ├── addrbook.json -│   │   │   ├── addrbook.json.bak -│   │   │   ├── config.yaml -│   │   │   ├── data -│   │   │   │   ├── genesis_stake_deposit.json -│   │   │   │   ├── genesis_theta_erc20_snapshot.json -│   │   │   │   ├── genesis_theta_erc20_snapshot_basic.json -│   │   │   │   └── theta-balance-height-7160047.json -│   │   │   ├── genesis -│   │   │   ├── genesis.bak -│   │   │   ├── key -│   │   │   │   └── encrypted -│   │   │   │   └── 9F1233798E905E173560071255140b4A8aBd3Ec6 -│   │   │   ├── key.plain -│   │   │   └── snapshot -│   │   ├── node2 -│   │   │   ├── addrbook.json -│   │   │   ├── addrbook.json.bak -│   │   │   ├── config.yaml -│   │   │   ├── genesis -│   │   │   ├── genesis.bak -│   │   │   ├── key -│   │   │   │   └── encrypted -│   │   │   │   └── 2E833968E5bB786Ae419c4d13189fB081Cc43bab -│   │   │   ├── key.plain -│   │   │   └── snapshot -│   │   ├── node3 -│   │   │   ├── addrbook.json -│   │   │   ├── addrbook.json.bak -│   │   │   ├── config.yaml -│   │   │   ├── genesis -│   │   │   ├── genesis.bak -│   │   │   ├── key -│   │   │   │   └── encrypted -│   │   │   │   └── C15E24083152dD76Ae6FC2aEb5269FF23d70330B -│   │   │   ├── key.plain -│   │   │   └── snapshot -│   │   ├── node4 -│   │   │   ├── addrbook.json -│   │   │   ├── addrbook.json.bak -│   │   │   ├── config.yaml -│   │   │   ├── genesis -│   │   │   ├── genesis.bak -│   │   │   ├── key -│   │   │   │   └── encrypted -│   │   │   │   └── 7631958d57Cf6a5605635a5F06Aa2ae2e000820e -│   │   │   ├── key.plain -│   │   │   └── snapshot -│   │   ├── thetacli -│   │   │   └── keys -│   │   │   ├── encrypted -│   │   │   │   ├── 0d2fD67d573c8ecB4161510fc00754d64B401F86 -│   │   │   │   ├── 21cA457E6E34162654aDEe28bcf235ebE5eee5De -│   │   │   │   ├── 2E833968E5bB786Ae419c4d13189fB081Cc43bab -│   │   │   │   ├── 70f587259738cB626A1720Af7038B8DcDb6a42a0 -│   │   │   │   ├── a5cdB2B0306518fb37b28bb63A1B2590FdE9b747 -│   │   │   │   └── cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 -│   │   │   └── plain -│   │   │   ├── 0d2fD67d573c8ecB4161510fc00754d64B401F86 -│   │   │   ├── 21cA457E6E34162654aDEe28bcf235ebE5eee5De -│   │   │   ├── 2E833968E5bB786Ae419c4d13189fB081Cc43bab -│   │   │   ├── 70f587259738cB626A1720Af7038B8DcDb6a42a0 -│   │   │   ├── a5cdB2B0306518fb37b28bb63A1B2590FdE9b747 -│   │   │   └── cd56123D0c5D6C1Ba4D39367b88cba61D93F5405 -│   │   └── walletnode -│   │   ├── config.yaml -│   │   ├── genesis -│   │   └── snapshot -│   ├── testnet_amber -│   │   ├── genesis_stake_deposit.json -│   │   ├── genesis_token_distribution.json -│   │   └── node -│   │   ├── config.yaml -│   │   └── snapshot -│   ├── testnet_sapphire -│   │   └── node -│   │   ├── config.yaml -│   │   └── snapshot -│   └── tools -│   ├── dump_storeview -│   │   └── dump_storeview.go -│   ├── encrypt_sk -│   │   └── encrypt_sk.go -│   ├── generate_genesis -│   │   └── generate_genesis.go -│   ├── hex_obj_parser -│   │   └── hex_obj_parser.go -│   ├── import_chain -│   │   └── import_chain.go -│   ├── inspect_data -│   │   └── inspect_data.go -│   ├── query_db -│   │   └── query_db.go -│   └── sign_hex_msg -│   └── sign_hex_msg.go -├── ledger -│   ├── execution -│   │   ├── executils.go -│   │   ├── executor.go -│   │   ├── regular_tx_execution_test.go -│   │   ├── smart_contract_tx_execution_test.go -│   │   ├── testdata -│   │   │   └── custom_token_transfer.json -│   │   ├── testutils.go -│   │   ├── tx_coinbase.go -│   │   ├── tx_deposit_stake.go -│   │   ├── tx_release_fund.go -│   │   ├── tx_reserve_fund.go -│   │   ├── tx_send.go -│   │   ├── tx_service_payment.go -│   │   ├── tx_slash.go -│   │   ├── tx_smart_contract.go -│   │   ├── tx_split_rule.go -│   │   └── tx_withdraw_stake.go -│   ├── ledger.go -│   ├── ledger_test.go -│   ├── state -│   │   ├── keys.go -│   │   ├── state.go -│   │   ├── state_test.go -│   │   ├── storeview.go -│   │   └── storeview_test.go -│   ├── testutils.go -│   ├── types -│   │   ├── account.go -│   │   ├── account_test.go -│   │   ├── coin.go -│   │   ├── coin_test.go -│   │   ├── const.go -│   │   ├── height_list.go -│   │   ├── height_list_test.go -│   │   ├── log.go -│   │   ├── log_test.go -│   │   ├── reserved_fund.go -│   │   ├── reserved_fund_test.go -│   │   ├── serialization.go -│   │   ├── serialization_test.go -│   │   ├── slash_intent.go -│   │   ├── slash_intent_test.go -│   │   ├── split_rule.go -│   │   ├── split_rule_test.go -│   │   ├── testutils.go -│   │   ├── tx.go -│   │   └── tx_test.go -│   └── vm -│   ├── analysis.go -│   ├── analysis_test.go -│   ├── asm -│   │   ├── asm.go -│   │   ├── asm_test.go -│   │   ├── compiler.go -│   │   ├── lex_test.go -│   │   └── lexer.go -│   ├── common.go -│   ├── contract.go -│   ├── contracts.go -│   ├── contracts_test.go -│   ├── doc.go -│   ├── errors.go -│   ├── exec.go -│   ├── exec_test.go -│   ├── gas.go -│   ├── gas_table.go -│   ├── gas_table_test.go -│   ├── gen_structlog.go -│   ├── instructions.go -│   ├── instructions_test.go -│   ├── int_pool_verifier.go -│   ├── int_pool_verifier_empty.go -│   ├── interface.go -│   ├── interpreter.go -│   ├── intpool.go -│   ├── intpool_test.go -│   ├── jump_table.go -│   ├── logger.go -│   ├── logger_test.go -│   ├── memory.go -│   ├── memory_table.go -│   ├── opcodes.go -│   ├── params -│   │   ├── bootnodes.go -│   │   ├── config.go -│   │   ├── dao.go -│   │   ├── denomination.go -│   │   ├── gas_table.go -│   │   ├── network_params.go -│   │   ├── protocol_params.go -│   │   └── version.go -│   ├── stack.go -│   ├── stack_table.go -│   ├── testdata -│   │   ├── erc20_token.json -│   │   ├── square_calculator.json -│   │   └── time_locked_safe.json -│   ├── vm.go -│   └── vm_test.go -├── mempool -│   ├── mempool.go -│   ├── mempool_message_handler.go -│   ├── mempool_message_handler_test.go -│   ├── mempool_test.go -│   ├── tx_bookkeeper.go -│   └── tx_bookkeeper_test.go -├── netsync -│   ├── encode.go -│   ├── encode_test.go -│   ├── request.go -│   ├── sync.go -│   └── sync_test.go -├── node -│   ├── node.go -│   └── node_test.go -├── p2p -│   ├── connection -│   │   ├── auth.go -│   │   ├── channel.go -│   │   ├── channel_group.go -│   │   ├── channel_group_test.go -│   │   ├── channel_test.go -│   │   ├── connection.go -│   │   ├── connection_test.go -│   │   ├── flowrate -│   │   │   ├── README.md -│   │   │   ├── flowrate.go -│   │   │   ├── io.go -│   │   │   ├── io_test.go -│   │   │   └── util.go -│   │   ├── packet.go -│   │   ├── packet_test.go -│   │   ├── recv_buffer.go -│   │   ├── recv_buffer_test.go -│   │   ├── send_buffer.go -│   │   └── send_buffer_test.go -│   ├── interface.go -│   ├── messenger -│   │   ├── addr_book.go -│   │   ├── addr_book_test.go -│   │   ├── disc_inbound_peer_listener.go -│   │   ├── disc_peer_discovery_message_handler.go -│   │   ├── disc_peer_discovery_message_handler_test.go -│   │   ├── disc_peer_no_response_test.go -│   │   ├── disc_seed_peer_connector.go -│   │   ├── discovery.go -│   │   ├── discovery_test.go -│   │   ├── messenger.go -│   │   ├── messenger_test.go -│   │   ├── nat_manager.go -│   │   └── nat_manager_test.go -│   ├── nat -│   │   ├── LICENSE -│   │   ├── README.md -│   │   ├── nat.go -│   │   ├── natpmp.go -│   │   └── upnp.go -│   ├── netutil -│   │   ├── net_addr.go -│   │   ├── net_addr_test.go -│   │   └── upnp.go -│   ├── peer -│   │   ├── peer.go -│   │   ├── peer_table.go -│   │   ├── peer_table_test.go -│   │   └── peer_test.go -│   ├── simulation -│   │   ├── simnet.go -│   │   └── simnet_test.go -│   └── types -│   ├── testutils.go -│   ├── types.go -│   └── types_test.go -├── p2pl -│   ├── common -│   │   └── common.go -│   ├── interface.go -│   ├── messenger -│   │   ├── disc_notifee.go -│   │   ├── messenger.go -│   │   ├── messenger_test.go -│   │   └── notify.go -│   ├── peer -│   │   ├── peer.go -│   │   └── peer_table.go -│   └── transport -│   ├── buffer -│   │   ├── chunk.go -│   │   ├── flowrate -│   │   │   ├── README.md -│   │   │   ├── flowrate.go -│   │   │   ├── io.go -│   │   │   ├── io_test.go -│   │   │   └── util.go -│   │   ├── recv_buffer.go -│   │   └── send_buffer.go -│   └── stream.go -├── report -│   └── reporter.go -├── rlp -│   ├── decode.go -│   ├── decode_tail_test.go -│   ├── decode_test.go -│   ├── doc.go -│   ├── encode.go -│   ├── encode_test.go -│   ├── encoder_example_test.go -│   ├── raw.go -│   ├── raw_test.go -│   └── typecache.go -├── rpc -│   ├── backup.go -│   ├── call.go -│   ├── client.go -│   ├── lib -│   │   └── rpc-codec -│   │   ├── LICENSE -│   │   ├── README.md -│   │   ├── go.mod -│   │   └── jsonrpc2 -│   │   ├── TODO -│   │   ├── all_test.go -│   │   ├── batch.go -│   │   ├── bench_test.go -│   │   ├── client.go -│   │   ├── context.go -│   │   ├── context_test.go -│   │   ├── doc.go -│   │   ├── errors.go -│   │   ├── example_test.go -│   │   ├── go.mod -│   │   ├── http.go -│   │   ├── http_test.go -│   │   ├── protocol_test.go -│   │   └── server.go -│   ├── query.go -│   ├── server.go -│   ├── tx.go -│   └── tx_test.go -├── snapshot -│   ├── chain_correction_export.go -│   ├── chain_export.go -│   ├── snapshot_export.go -│   └── snapshot_import.go -├── store -│   ├── database -│   │   ├── backend -│   │   │   ├── aerospike.go -│   │   │   ├── aerospike_test.go -│   │   │   ├── badgerdb.go -│   │   │   ├── badgerdb_test.go -│   │   │   ├── leveldb.go -│   │   │   ├── leveldb_test.go -│   │   │   ├── memdb.go -│   │   │   ├── memdb_test.go -│   │   │   ├── mgodb.go -│   │   │   ├── mgodb_test.go -│   │   │   ├── mongodb.go -│   │   │   └── mongodb_test.go -│   │   └── interface.go -│   ├── errors.go -│   ├── interface.go -│   ├── kvstore -│   │   ├── kvstore.go -│   │   └── kvstore_test.go -│   ├── treestore -│   │   ├── treestore.go -│   │   └── treestore_test.go -│   └── trie -│   ├── database.go -│   ├── encoding.go -│   ├── encoding_test.go -│   ├── errors.go -│   ├── hasher.go -│   ├── iterator.go -│   ├── iterator_test.go -│   ├── node.go -│   ├── node_test.go -│   ├── proof.go -│   ├── proof_test.go -│   ├── secure_trie.go -│   ├── secure_trie_test.go -│   ├── size.go -│   ├── size_test.go -│   ├── sync.go -│   ├── sync_test.go -│   ├── trie.go -│   └── trie_test.go -├── tree.out -├── version -│   └── version_number.txt -└── wallet - ├── coldwallet - │   ├── coldwallet.go - │   ├── coldwallet_test.go - │   ├── hid - │   │   ├── LICENSE.md - │   │   ├── README.md - │   │   ├── appveyor.yml - │   │   ├── go.mod - │   │   ├── hid.go - │   │   ├── hid_disabled.go - │   │   ├── hid_enabled.go - │   │   ├── hid_test.go - │   │   ├── hidapi - │   │   │   ├── AUTHORS.txt - │   │   │   ├── LICENSE-bsd.txt - │   │   │   ├── LICENSE-gpl3.txt - │   │   │   ├── LICENSE-orig.txt - │   │   │   ├── LICENSE.txt - │   │   │   ├── README.txt - │   │   │   ├── hidapi - │   │   │   │   └── hidapi.h - │   │   │   ├── libusb - │   │   │   │   └── hid.c - │   │   │   ├── mac - │   │   │   │   └── hid.c - │   │   │   └── windows - │   │   │   └── hid.c - │   │   ├── libusb - │   │   │   ├── AUTHORS - │   │   │   ├── COPYING - │   │   │   └── libusb - │   │   │   ├── config.h - │   │   │   ├── core.c - │   │   │   ├── descriptor.c - │   │   │   ├── hotplug.c - │   │   │   ├── hotplug.h - │   │   │   ├── io.c - │   │   │   ├── libusb.h - │   │   │   ├── libusbi.h - │   │   │   ├── os - │   │   │   │   ├── darwin_usb.c - │   │   │   │   ├── darwin_usb.h - │   │   │   │   ├── haiku_pollfs.cpp - │   │   │   │   ├── haiku_usb.h - │   │   │   │   ├── haiku_usb_backend.cpp - │   │   │   │   ├── haiku_usb_raw.cpp - │   │   │   │   ├── haiku_usb_raw.h - │   │   │   │   ├── linux_netlink.c - │   │   │   │   ├── linux_udev.c - │   │   │   │   ├── linux_usbfs.c - │   │   │   │   ├── linux_usbfs.h - │   │   │   │   ├── netbsd_usb.c - │   │   │   │   ├── openbsd_usb.c - │   │   │   │   ├── poll_posix.c - │   │   │   │   ├── poll_posix.h - │   │   │   │   ├── poll_windows.c - │   │   │   │   ├── poll_windows.h - │   │   │   │   ├── sunos_usb.c - │   │   │   │   ├── sunos_usb.h - │   │   │   │   ├── threads_posix.c - │   │   │   │   ├── threads_posix.h - │   │   │   │   ├── threads_windows.c - │   │   │   │   ├── threads_windows.h - │   │   │   │   ├── wince_usb.c - │   │   │   │   ├── wince_usb.h - │   │   │   │   ├── windows_common.h - │   │   │   │   ├── windows_nt_common.c - │   │   │   │   ├── windows_nt_common.h - │   │   │   │   ├── windows_usbdk.c - │   │   │   │   ├── windows_usbdk.h - │   │   │   │   ├── windows_winusb.c - │   │   │   │   └── windows_winusb.h - │   │   │   ├── strerror.c - │   │   │   ├── sync.c - │   │   │   ├── version.h - │   │   │   └── version_nano.h - │   │   ├── wchar.go - │   │   └── wchar_test.go - │   ├── keystore - │   │   ├── driver.go - │   │   ├── nano_ledger.go - │   │   ├── trezor - │   │   │   ├── messages.pb.go - │   │   │   ├── messages.proto - │   │   │   ├── protobuf.go - │   │   │   ├── transport.go - │   │   │   ├── trezor.go - │   │   │   ├── types.pb.go - │   │   │   ├── types.proto - │   │   │   └── ui.go - │   │   └── trezor.go - │   └── usb_hub.go - ├── softwallet - │   ├── keystore - │   │   ├── key.go - │   │   ├── keystore.go - │   │   ├── ks_encrypted.go - │   │   ├── ks_encrypted_test.go - │   │   ├── ks_plain.go - │   │   ├── ks_plain_test.go - │   │   ├── testdata - │   │   │   ├── dupes - │   │   │   │   ├── 1 - │   │   │   │   ├── 2 - │   │   │   │   └── foo - │   │   │   ├── keystore - │   │   │   │   ├── README - │   │   │   │   ├── UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8 - │   │   │   │   ├── aaa - │   │   │   │   ├── empty - │   │   │   │   ├── foo - │   │   │   │   │   └── fd9bd350f08ee3c0c19b85a8e16114a11a60aa4e - │   │   │   │   ├── garbage - │   │   │   │   ├── no-address - │   │   │   │   ├── zero - │   │   │   │   └── zzz - │   │   │   ├── test_vector.json - │   │   │   └── very-light-scrypt.json - │   │   └── testutils.go - │   ├── softwallet.go - │   └── softwallet_test.go - ├── types - │   ├── derivation_path.go - │   └── wallet.go - └── wallet.go - -180 directories, 852 files diff --git a/version/gitignore b/version/.gitignore similarity index 100% rename from version/gitignore rename to version/.gitignore diff --git a/version/version_generated.go b/version/version_generated.go deleted file mode 100644 index 63784639..00000000 --- a/version/version_generated.go +++ /dev/null @@ -1,6 +0,0 @@ -package version -const ( - Timestamp = "Wed Jul 28 20:00:19 UTC 2021" - Version = "3.1.0" - GitHash = "bf0d20905b991b2799ee3b35b1064f323520871a" -) From 9562bbf0d9cef39b0f0878e8299d8fbb2a377e0f Mon Sep 17 00:00:00 2001 From: Jieyi Long Date: Sun, 15 Aug 2021 16:22:03 -0700 Subject: [PATCH 20/20] Code clean up --- cmd/thetacli/cmd/tx/reserve_fund.go | 23 ++------------ cmd/thetacli/cmd/tx/service_payment.go | 43 ++++++++++++-------------- cmd/thetacli/cmd/tx/utils.go | 26 ---------------- ledger/types/tx.go | 27 ---------------- 4 files changed, 22 insertions(+), 97 deletions(-) diff --git a/cmd/thetacli/cmd/tx/reserve_fund.go b/cmd/thetacli/cmd/tx/reserve_fund.go index b652d2a9..30af9a77 100644 --- a/cmd/thetacli/cmd/tx/reserve_fund.go +++ b/cmd/thetacli/cmd/tx/reserve_fund.go @@ -12,7 +12,7 @@ import ( "github.com/thetatoken/theta/ledger/types" "github.com/thetatoken/theta/rpc" -// "github.com/ybbus/jsonrpc" + // "github.com/ybbus/jsonrpc" rpcc "github.com/ybbus/jsonrpc" ) @@ -27,21 +27,6 @@ var reserveFundCmd = &cobra.Command{ } func doReserveFundCmd(cmd *cobra.Command, args []string) { - - - // formatted0, err0 := json.MarshalIndent(cmd, "", " ") - // if err0 != nil { - // utils.Error("Failed to parse server response: %v\n", err0) - // } - // //fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) - // // Verbose output makes parsing json difficult - // fmt.Printf("cmd: %s\n", formatted0) - - fmt.Printf("cmd: %s\n", cmd.Short) - fmt.Printf("config: %s\n", cmd.Flag("config").Value.String()) - - - wallet, fromAddress, err := walletUnlock(cmd, fromFlag, passwordFlag) if err != nil { return @@ -97,10 +82,6 @@ func doReserveFundCmd(cmd *cobra.Command, args []string) { } reserveFundTx.SetSignature(fromAddress, sig) - // reqformatted, err := json.MarshalIndent(reserveFundTx, "", " ") - // fmt.Printf("ReserveFundRequest:\n%s\n", reqformatted) - - raw, err := types.TxToBytes(reserveFundTx) if err != nil { utils.Error("Failed to encode transaction: %v\n", err) @@ -133,7 +114,7 @@ func doReserveFundCmd(cmd *cobra.Command, args []string) { //fmt.Printf("Successfully broadcasted transaction:\n%s\n", formatted) // Verbose output makes parsing json difficult fmt.Printf("%s\n", formatted) - + //fmt.Printf("Successfully broadcasted transaction.\n") } diff --git a/cmd/thetacli/cmd/tx/service_payment.go b/cmd/thetacli/cmd/tx/service_payment.go index 03042584..25f9b731 100644 --- a/cmd/thetacli/cmd/tx/service_payment.go +++ b/cmd/thetacli/cmd/tx/service_payment.go @@ -30,10 +30,7 @@ var servicePaymentCmd = &cobra.Command{ } func doServicePaymentCmd(cmd *cobra.Command, args []string) { - var debugging = false - if debuggingFlag { - debugging = true - } + var debugging = debuggingFlag walletType := getWalletType(cmd) if walletType == wtypes.WalletTypeSoft && len(fromFlag) == 0 { utils.Error("The from address cannot be empty") // we don't need to specify the "from address" for hardware wallets @@ -57,14 +54,14 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { var toAddress = common.HexToAddress(toFlag) var err error - if (debugging) { + if debugging { fmt.Printf("fromAddress: %s\n", fromAddress) fmt.Printf("toAddress: %s\n", toAddress) fmt.Printf("passwordFlag: %s\n", passwordFlag) } if onChainFlag { -// if 1 == 1 { + // if 1 == 1 { twallet, toAddress, err = walletUnlockWithPath(cmd, toFlag, pathFlag, passwordFlag) if err != nil || twallet == nil { return @@ -88,7 +85,7 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { utils.Error("Failed to parse fee") } - if (debugging) { + if debugging { fmt.Printf("tfuel: %d\n", tfuel) fmt.Printf("fee: %d\n", fee) } @@ -116,7 +113,7 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { //Signature: } - if (debugging) { + if debugging { fmt.Printf("paymentSeqFlag: %d\n", paymentSeqFlag) fmt.Printf("reserveSeqFlag: %d\n", reserveSeqFlag) fmt.Printf("resourceIDFlag: %s\n", resourceIDFlag) @@ -128,16 +125,16 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { ThetaWei: new(big.Int).SetUint64(0), TFuelWei: fee, }, - Source: sinput, - Target: tinput, + Source: sinput, + Target: tinput, PaymentSequence: paymentSeqFlag, ReserveSequence: reserveSeqFlag, - ResourceID: resourceIDFlag, + ResourceID: resourceIDFlag, } // Set the Source Signature if onChainFlag { - if (debugging) { + if debugging { fmt.Printf("Set the Source Signature On-Chain\n") } //ssig, err := crypto.UnmarshalJSON([]byte(sourceSignatureFlag)) @@ -147,7 +144,7 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { } servicePaymentTx.SetSourceSignature(ssig) } else { - if (debugging) { + if debugging { fmt.Printf("Set the Source Signature Off-Chain\n") } ssig, err := swallet.Sign(fromAddress, servicePaymentTx.SourceSignBytes(chainIDFlag)) @@ -157,14 +154,14 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { //fmt.Printf("ssig: %s\n", ssig) servicePaymentTx.SetSourceSignature(ssig) - if (debugging) { + if debugging { fmt.Printf("Set the Source Signature Off-Chain Finished\n") } } // Set the Target Signature if onChainFlag { - if (debugging) { + if debugging { fmt.Printf("Set the Target Signature On-Chain\n") } tsig, err := twallet.Sign(toAddress, servicePaymentTx.TargetSignBytes(chainIDFlag)) @@ -173,7 +170,7 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { } servicePaymentTx.SetTargetSignature(tsig) } else { - if (debugging) { + if debugging { fmt.Printf("Set the Target Signature Off-Chain\n") } tsig, err := crypto.SignatureFromBytes([]byte("unsigned")) @@ -181,12 +178,12 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { utils.Error("Failed to convert passed signature: %v\n", err) } servicePaymentTx.SetTargetSignature(tsig) - if (debugging) { + if debugging { fmt.Printf("Set the Target Signature Off-Chain Finished\n") } } - if (debugging) { + if debugging { formatted, err := json.MarshalIndent(servicePaymentTx, "", " ") if err != nil { utils.Error("Failed to parse off-chain transaction: %v\n", err) @@ -199,19 +196,19 @@ func doServicePaymentCmd(cmd *cobra.Command, args []string) { utils.Error("Failed to encode transaction: %v\n", err) } - if (debugging) { + if debugging { fmt.Printf(" raw: %s\n", hex.EncodeToString(raw)) } signedTx := hex.EncodeToString(raw) - if (debugging) { + if debugging { fmt.Printf(" signedTx: %s\n", signedTx) } if onChainFlag { - if dryRunFlag { - if (debugging) { + if dryRunFlag { + if debugging { formatted, err := json.MarshalIndent(servicePaymentTx, "", " ") if err != nil { utils.Error("Failed to parse off-chain transaction: %v\n", err) @@ -278,7 +275,7 @@ func init() { servicePaymentCmd.Flags().StringVar(&passwordFlag, "password", "", "password to unlock the wallet") servicePaymentCmd.Flags().BoolVar(&dryRunFlag, "dry_run", false, "Dry Run(don't execute) the On-Chain transaction") servicePaymentCmd.Flags().BoolVar(&debuggingFlag, "debugging", false, "Print verbose debugging output") - + servicePaymentCmd.MarkFlagRequired("chain") servicePaymentCmd.MarkFlagRequired("from") servicePaymentCmd.MarkFlagRequired("to") diff --git a/cmd/thetacli/cmd/tx/utils.go b/cmd/thetacli/cmd/tx/utils.go index 95533a05..53e1d038 100644 --- a/cmd/thetacli/cmd/tx/utils.go +++ b/cmd/thetacli/cmd/tx/utils.go @@ -97,32 +97,6 @@ func SoftWalletUnlock(cfgPath, addressStr string, password string) (wtypes.Walle return wallet, address, nil } -func SoftWalletUnlockPW(cfgPath, addressStr string, password string) (wtypes.Wallet, common.Address, error) { - wallet, err := wallet.OpenWallet(cfgPath, wtypes.WalletTypeSoft, true) - if err != nil { - fmt.Printf("Failed to open wallet: %v\n", err) - return nil, common.Address{}, err - } - - //prompt := fmt.Sprintf("Please enter pasword: ") - //password, err := utils.GetPassword(prompt) - //if err != nil { - // fmt.Printf("Failed to get password: %v\n", err) - // return nil, common.Address{}, err - //} - - // password:= "qwertyuiop" - - address := common.HexToAddress(addressStr) - err = wallet.Unlock(address, password, nil) - if err != nil { - fmt.Printf("Failed to unlock address %v: %v\n", address.Hex(), err) - return nil, common.Address{}, err - } - - return wallet, address, nil -} - func getWalletType(cmd *cobra.Command) (walletType wtypes.WalletType) { walletTypeStr := cmd.Flag("wallet").Value.String() if walletTypeStr == "nano" { diff --git a/ledger/types/tx.go b/ledger/types/tx.go index a5d47095..382b6ffa 100644 --- a/ledger/types/tx.go +++ b/ledger/types/tx.go @@ -585,17 +585,8 @@ func (a *ServicePaymentTx) UnmarshalJSON(data []byte) error { func (_ *ServicePaymentTx) AssertIsTx() {} func (tx *ServicePaymentTx) SourceSignBytes(chainID string) []byte { - debugging := false signBytes := encodeToBytes(chainID) - //formatted, err := json.MarshalIndent(result, "", " ") - //if err != nil { - // utils.Error("Failed : %v\n", err) - //} - if (debugging) { - fmt.Printf(" signBytes: %s\n", hex.EncodeToString(signBytes)) - } - source := tx.Source target := tx.Target fee := tx.Fee @@ -604,22 +595,8 @@ func (tx *ServicePaymentTx) SourceSignBytes(chainID string) []byte { tx.Target = TxInput{Address: target.Address} tx.Fee = NewCoins(0, 0) - if (debugging) { - formatted, err := json.MarshalIndent(tx, "", " ") - if err != nil { - fmt.Printf("Failed : %v\n", err) - } - fmt.Printf("tx to sign: %s\n", formatted) - } - txBytes, _ := TxToBytes(tx) - if (debugging) { - fmt.Printf(" txBytes: %s\n", hex.EncodeToString(txBytes)) - } signBytes = append(signBytes, txBytes...) - if (debugging) { - fmt.Printf(" append signBytes: %s\n", hex.EncodeToString(signBytes)) - } tx.Source = source tx.Target = target @@ -627,10 +604,6 @@ func (tx *ServicePaymentTx) SourceSignBytes(chainID string) []byte { signBytes = addPrefixForSignBytes(signBytes) - if (debugging) { - fmt.Printf(" bytesToBeSigned: %s\n", hex.EncodeToString(signBytes)) - } - return signBytes }