Revision | e33079fa2ab514f3eec82a88b183405dab0c2860 (tree) |
---|---|
Zeit | 2019-10-09 10:54:23 |
Autor | Chengcheng Zhang <943420582@qq.c...> |
Commiter | Chengcheng Zhang |
refine callhtlc
@@ -463,31 +463,28 @@ var submitPaymentCmd = &cobra.Command{ | ||
463 | 463 | |
464 | 464 | switch action { |
465 | 465 | case "deployhtlc": |
466 | - spendParametersNum := len(args) - 3 | |
467 | - for i := 0; i < spendParametersNum; i++ { | |
468 | - wa = append(wa, args[3+i]) | |
466 | + for i := 3; i < len(args); i++ { | |
467 | + wa = append(wa, args[i]) | |
469 | 468 | was = append(was, wa) |
470 | 469 | wa = []string{} |
471 | 470 | } |
472 | - // case "callhtlc": | |
473 | - // if _, err := hex.DecodeString(preimage); err != nil || len(preimage) == 0 { | |
474 | - // fmt.Println("The part field of preimage is invalid:", preimage) | |
475 | - // os.Exit(0) | |
476 | - // } | |
471 | + case "callhtlc": | |
472 | + // callhtlc need 6 arguments at least | |
473 | + if len(args) < 6 { | |
474 | + fmt.Println("callhtlc need 3 arguments at least, len(args) is:", len(args)) | |
475 | + os.Exit(0) | |
476 | + } | |
477 | 477 | |
478 | - // if _, err := hex.DecodeString(spendUTXOSig); err != nil || len(spendUTXOSig) != 128 { | |
479 | - // fmt.Println("The part field of spendUTXOSig is invalid:", spendUTXOSig) | |
480 | - // os.Exit(0) | |
481 | - // } | |
478 | + wa = append(wa, args[3], args[4], "") | |
479 | + was = append(was, wa) | |
480 | + wa = []string{} | |
482 | 481 | |
483 | - // if _, err := hex.DecodeString(spendWalletSig); err != nil || len(spendWalletSig) != 128 { | |
484 | - // fmt.Println("The part field of spendWalletSig is invalid:", spendWalletSig) | |
485 | - // os.Exit(0) | |
486 | - // } | |
482 | + for i := 5; i < len(args); i++ { | |
483 | + wa = append(wa, args[i]) | |
484 | + was = append(was, wa) | |
485 | + wa = []string{} | |
486 | + } | |
487 | 487 | |
488 | - // spendUTXOSignatures = append(spendUTXOSignatures, preimage, spendUTXOSig, "") | |
489 | - // spendWalletSignatures = append(spendWalletSignatures, spendWalletSig) | |
490 | - // sigs = append(sigs, spendUTXOSignatures, spendWalletSignatures) | |
491 | 488 | // case "cancelhtlc": |
492 | 489 | // if _, err := hex.DecodeString(spendUTXOSig); err != nil || len(spendUTXOSig) != 128 { |
493 | 490 | // fmt.Println("The part field of spendUTXOSig is invalid:", spendUTXOSig) |
@@ -549,8 +546,6 @@ var submitPaymentCmd = &cobra.Command{ | ||
549 | 546 | fmt.Println("action is invalid:", action) |
550 | 547 | os.Exit(0) |
551 | 548 | } |
552 | - // spendWalletSignatures = append(spendWalletSignatures, spendWalletSig) | |
553 | - // sigs = append(sigs, spendUTXOSignatures, spendWalletSignatures) | |
554 | 549 | |
555 | 550 | server := &swap.Server{ |
556 | 551 | IP: ip, |
@@ -204,11 +204,11 @@ func BuildUnlockedTx(s *Server, guid, contractUTXOID, contractAsset, receiver st | ||
204 | 204 | OutputID: contractUTXOID, |
205 | 205 | } |
206 | 206 | |
207 | - spendWalletInput := SpendWalletInput{ | |
208 | - Type: "spend_wallet", | |
209 | - AssetID: contractAsset, | |
210 | - Amount: contractAmount, | |
211 | - } | |
207 | + // spendWalletInput := SpendWalletInput{ | |
208 | + // Type: "spend_wallet", | |
209 | + // AssetID: contractAsset, | |
210 | + // Amount: contractAmount, | |
211 | + // } | |
212 | 212 | |
213 | 213 | // outputs: |
214 | 214 | controlAddressOutput := ControlAddressOutput{ |
@@ -219,7 +219,8 @@ func BuildUnlockedTx(s *Server, guid, contractUTXOID, contractAsset, receiver st | ||
219 | 219 | } |
220 | 220 | |
221 | 221 | var inputs, outputs []interface{} |
222 | - inputs = append(inputs, spendUTXOInput, spendWalletInput) | |
222 | + // inputs = append(inputs, spendUTXOInput, spendWalletInput) | |
223 | + inputs = append(inputs, spendUTXOInput) | |
223 | 224 | outputs = append(outputs, controlAddressOutput) |
224 | 225 | payload, err := json.Marshal(buildTxReq{ |
225 | 226 | GUID: guid, |