Skip to content
TheChatArchiveThe Chat Archive
Googlepalm-2· GoogleHugging Face Arena Human Preference 55K

write some go code to generate new bitcoin wallets and listen for new incoming…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Metallama-2-13b-chat’s answer.
  1. User

    write some go code to generate new bitcoin wallets and listen for new incoming transactions on a local node for a web app

  2. Google Assistant
    package main
    
    import (
    	"fmt"
    	"log"
    	"os"
    
    	"github.com/btcsuite/btcd/chaincfg"
    	"github.com/btcsuite/btcd/rpcclient"
    )
    
    func main() {
    	// Connect to a Bitcoin Core RPC server.
    	conn, err := rpcclient.New(&rpcclient.ConnConfig{
    		Host:         "localhost:8332",
    		User:         "bitcoin",
    		Pass:         "password",
    		HTTPPostMode: true,
    	})
    	if err != nil {
    		log.Fatal(err)
    	}
    
    	// Create a new Bitcoin wallet.
    	wallet, err := btcd.NewWallet(chaincfg.MainNetParams, conn)
    	if err != nil {
    		log.Fatal(err)
    	}
    
    	// Generate a new Bitcoin address.
    	address, err := wallet.NewAddress()
    	if err != nil {
    		log.Fatal(err)
    	}
    
    	// Print the new Bitcoin address.
    	fmt.Println(address)
    
    	// Listen for new incoming transactions on the local node.
    	for {
    		// Get the latest block from the local node.
    		block, err := conn.GetBlock(nil)
    		if err != nil {
    			log.Fatal(err)
    		}
    
    		// Iterate over the transactions in the block.
    		for _, tx := range block.Transactions {
    			// Check if the transaction is for the new Bitcoin address.
    			if tx.ToAddress == address {
    				// The transaction is for the new Bitcoin address.
    				// Do something with the transaction.
    			}
    		}
    	}
    }
    
  3. User

    can you finish

  4. Google Assistant

    Sure, here is the rest of the code:

    // Write the new Bitcoin address to a file.
    err = os.WriteFile("address.txt", []byte(address), 0644)
    if err != nil {
    	log.Fatal(err)
    }
    
    // Start a web server.
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    	// Get the new Bitcoin address from the file.
    	data, err := os.ReadFile("address.txt")
    	if err != nil {
    		log.Fatal(err)
    	}
    
    	// Write the new Bitcoin address to the response.
    	w.Write(data)
    })
    
    // Listen for HTTP requests on port 8080.
    log.Fatal(http.ListenAndServe(":8080", nil))
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.