// prepare a signed transaction func sign_tx(tx *btc.Tx) { for in := range tx.TxIn { uo := UO(unspentOuts[in]) var found bool for j := range publ_addrs { if publ_addrs[j].Owns(uo.Pk_script) { found = true er := tx.Sign(in, uo.Pk_script, btc.SIGHASH_ALL, publ_addrs[j].Pubkey, priv_keys[j][:]) if er != nil { fmt.Println("Error signing input", in, "of", len(tx.TxIn)) fmt.Println("...", er.Error()) } break } } if !found { fmt.Println("WARNING: You do not have key for", hex.EncodeToString(uo.Pk_script)) } } }