mirror of
				https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
				synced 2025-10-31 10:27:29 +00:00 
			
		
		
		
	Create 17_1_sendtransaction.go
This commit is contained in:
		
							parent
							
								
									15bb77cd9a
								
							
						
					
					
						commit
						8fbe00e938
					
				
							
								
								
									
										36
									
								
								src/17_1_sendtransaction.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/17_1_sendtransaction.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | |||||||
|  | package main | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"log" | ||||||
|  | 	"fmt" | ||||||
|  | 	"github.com/btcsuite/btcd/rpcclient" | ||||||
|  | 	"github.com/btcsuite/btcutil" | ||||||
|  | 	"github.com/btcsuite/btcd/chaincfg" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | func main() { | ||||||
|  | 	connCfg := &rpcclient.ConnConfig{ | ||||||
|  | 		Host:         "localhost:18332", | ||||||
|  | 		User:         "StandUp", | ||||||
|  | 		Pass:         "431451790e3eee1913115b9dd2fbf0ac", | ||||||
|  | 		HTTPPostMode: true, | ||||||
|  | 		DisableTLS:   true, | ||||||
|  | 	} | ||||||
|  | 	client, err := rpcclient.New(connCfg, nil) | ||||||
|  | 	if err != nil { | ||||||
|  | 		log.Fatal(err) | ||||||
|  | 	} | ||||||
|  | 	defer client.Shutdown() | ||||||
|  | 
 | ||||||
|  | 	defaultNet := &chaincfg.TestNet3Params | ||||||
|  | 	addr, err := btcutil.DecodeAddress("n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi", defaultNet) | ||||||
|  | 	if err != nil { | ||||||
|  | 		log.Fatal(err) | ||||||
|  | 	} | ||||||
|  | 	sent, err := client.SendToAddress(addr, btcutil.Amount(1e4)) | ||||||
|  | 	if err != nil { | ||||||
|  | 		log.Fatal(err) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	fmt.Println(sent) | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user