// Synchronously submit a single transaction func (r *Remote) Submit(tx data.Transaction) (*SubmitResult, error) { _, raw, err := data.Raw(tx) if err != nil { return nil, err } cmd := &SubmitCommand{ Command: newCommand("submit"), TxBlob: fmt.Sprintf("%X", raw), } r.outgoing <- cmd <-cmd.Ready if cmd.CommandError != nil { return nil, cmd.CommandError } return cmd.Result, nil }
// Synchronously submit a single transaction func (r *Remote) SubmitBatch(txs []data.Transaction) ([]*SubmitResult, error) { commands := make([]*SubmitCommand, len(txs)) results := make([]*SubmitResult, len(txs)) for i := range txs { _, raw, err := data.Raw(txs[i]) if err != nil { return nil, err } cmd := &SubmitCommand{ Command: newCommand("submit"), TxBlob: fmt.Sprintf("%X", raw), } r.outgoing <- cmd commands[i] = cmd } for i := range commands { <-commands[i].Ready results[i] = commands[i].Result } return results, nil }
func outputTx(c *cli.Context, tx data.Transaction) { if !c.GlobalBool("json") { hash, raw, err := data.Raw(tx) checkErr(err) if c.GlobalBool("binary") { os.Stdout.Write(raw) } else { fmt.Printf("Hash: %s\nRaw: %X\n", hash, raw) } } if c.GlobalBool("json") || !c.GlobalBool("binary") { // Print it in JSON out, err := json.Marshal(tx) checkErr(err) fmt.Println(string(out)) } if c.GlobalBool("submit") { submitTx(tx) } }